コード例 #1
0
ファイル: cons.cpp プロジェクト: Pudak/cdl
int main()
{
	Cat Scratchy; // eroare: constructorul implicit nu mai este sintetizat
	Cat Tom("blue"); // ok
	Cat *Sylvester = new Cat("black and white"); 
	// alocare memorie și apelează constructor
	delete Sylvester; // apelează destructor și eliberează memoria
	return 0;
}
コード例 #2
0
ファイル: 10_83.cpp プロジェクト: 1040003585/LearnedCandCPP
void main()
{
	student Henry(1980,11,12),Tom(1976,3,25);
	cout<<"Henry's birthday is ";Henry.disp(); 
	cout<<"Tom's birthday is ";Tom.disp();
	if((Henry-Tom)>0)
	    cout<<"Tom is older than Henry "<<Henry-Tom<<" days."<<endl;
	else
		cout<<"Henry is older than Tom "<<Tom-Henry<<" days."<<endl;
}