#include <iostream>
#include <conio.h>
using namespace std;
class Ucapan{
public:
Ucapan(){kata="Hello World!";}
Ucapan(char*kata_awal);
void cetak(){cout<<kata<<endl;}
private:
char*kata;
};
Ucapan::Ucapan(char*kata_awal){
kata=kata_awal;
}
int main()
{ Ucapan kalimat,kalimat2("Wellcome to Algorithms");
kalimat.cetak();
cout<<endl;
kalimat2.cetak();
getch();
return 0;
system("PAUSE");
return EXIT_SUCCESS;
}
Hasil: