[ create a new paste ] login | about

Link: http://codepad.org/Ghv5oeHJ    [ raw code | output | fork ]

C++, pasted on Jun 24:
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
class Fish
{
private:
	int priv_id;
	void funct()
	{
		cout<<"Don't run me!!";
	}
protected:
	int prot_id;

public:
  int ID;
  Fish(int id):priv_id(id+1), prot_id(id+2), ID(id)
	{}
};

class GoldFish : public Fish
{
public:
	void funct()
	{
		cout << "\nYou ran me!!";
	}

	int getprot_id()
	{
		return prot_id;
	}
	GoldFish(int id):Fish(id){}
};


int main()
{
	GoldFish GF(33);
	cout << "\n" << GF.getprot_id();
	GF.funct();

//	Fish* fPtr = &GF;
//	((GoldFish*)fPtr)->funct();

	return 1;
}


Output:
1
2
3

35
You ran me!!


Create a new paste based on this one


Comments: