My Blog List

Tuesday, October 26, 2010

Reviewing Concepts: Portal Inheritance, Object Method

This GDB was configured as "x86_64-apple-darwin".tty /dev/ttys000
Loading program into debugger…
Program loaded.
run
[Switching to process 45244]
Running…
Portal Pilots: Encountered a Time Portal
Portal Type is a Bridge

Debugger stopped.
Program exited with status value:0.

.....

#include <stdio.h>
#import <Foundation/Foundation.h>

// Portalinherit: Simple Portal Inheritance

//Based on: inheriting base-class methods QStart page 125

@interface Portal : NSObject

-(void) print;

@end

@implementation Portal
-(void) print
{
    printf("Portal Pilots: Encountered a Time Portal\n");  
}
@end

@interface Bridge : Portal

-(void) print2;

@end

@implementation Bridge
-(void) print2
{
    printf("Portal Type is a Bridge\n");  
}
@end

int main (void)
{
  
    // Instantiate the 'Bridge' class
    // create an object called 'bridge' that points to the Bridge instance
  
    Bridge *bridge = [Bridge new];
  
    // execute an object method (page 83)
    //  syntax is '[object object_method_name]'
  
    [bridge print];
    [bridge print2];
  
  
  
    return 0;
}

No comments:

Post a Comment