- main.cpp
#include <iostream>
#include "Sally.h"
using namespace std;
int main()
{
Sally sallyObject;
//first
sallyObject.printCrap();
//third
Sally *sallyPointer = &sallyObject;
sallyPointer->printCrap();
//third
Sally so;
//first
cout << "fourth" << endl;
//fourth
//second
return 0;
}
- Sally.h
#ifndef SALLY_H
#define SALLY_H
class Sally
{
public:
Sally();
~Sally();
void printCrap();
protected:
private:
};
#endif // SALLY_H
- Sally.cpp
#include "Sally.h"
#include <iostream>
using namespace std;
Sally::~Sally()
{
cout << "second" << endl;
}
void Sally::printCrap()
{
cout << "third" << endl;
}
Sally::Sally()
{
cout << "first" << endl;
}
网友评论