This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "private_var.h" | |
#include <stdio.h> | |
#include <stdlib.h> | |
struct Contact | |
{ | |
int mobile_number; | |
int home_number; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef PRIVATE_VAR | |
#define PRIVATE_VAR | |
struct Contact; | |
struct Contact * create_contact(); | |
void delete_contact( struct Contact * some_contact ); | |
#endif /* PRIVATE_VAR */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "private_var.h" | |
#include <stdio.h> | |
int main() | |
{ | |
struct Contact * Tony; | |
Tony = create_contact(); | |
int * mobile_number_is_here = (int *)Tony; | |
printf("Mobile number: %d\n", *mobile_number_is_here); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "private_funct.h" | |
int main() | |
{ | |
struct Contact * Tony; | |
Tony = create_contact(); | |
// print_numbers( Tony ); | |
// will cause compile time error | |
delete_contact( Tony ); | |
return 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "private_funct.h" | |
#include <stdio.h> | |
#include <stdlib.h> | |
struct Contact | |
{ | |
int mobile_number; | |
int home_number; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef PRIVATE_FUNCT_H | |
#define PRIVATE_FUNCT_H | |
struct Contact; | |
struct Contact * create_contact(); | |
static void print_numbers( struct Contact * some_contact ); | |
void delete_contact( struct Contact * my_points ); | |
#endif /* PRIVATE_FUNCT_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class Device { | |
public: | |
int serial_number = 12345678; | |
void turn_on() { | |
cout << "Device is on" << endl; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class Device { | |
public: | |
int serial_number = 12345678; | |
void turn_on() { | |
cout << "Device is on" << endl; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class Device { | |
public: | |
// constructor | |
Device() { | |
cout << "Device constructor called" << endl; | |
} | |
// destructor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class Device { | |
public: | |
void turn_on() { | |
cout << "Device is on." << endl; | |
} | |
}; |