Computer Forum  

Go Back   Computer Forum > Computer Forums > Programming Forum > C++ Forum

C++ Forum C++ Forum. C++ Programming


A C++ program?

C++ Forum

C++ Forum. C++ Programming


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-12-2008, 09:50 AM
Junior Member
 
Join Date: Sep 2008
Posts: 1
chinju RSS Feed
A C++ program?

please write one example related on oops(object oriented programming?
Reply With Quote
  #2 (permalink)  
Old 09-12-2008, 09:57 AM
Junior Member
 
Join Date: Jun 2008
Posts: 5
jplatt39 RSS Feed
Notice: I declare the class Greeting, I then get to main where I declare an object Hello of class greeting, and since I used the constructor to do everything I wanted to do with it (or rather used the method Doit() which is renamed from my original constructor and called in the one which doesn't throw errors) I simply told the operating system my program was terminating normally (return 0 in Unix derivatives like Linux) and bailed.

//Hello.cc Sample C++ program featuring an object with methods
// uses a couple of kludges because my original constructor threw errors
// from here to Samarkand. Compiled with GCC on June 14, 2008.

#include <iostream>

using namespace std;

class Greeting{
char Name[40];
public:
Greeting(){Doit();};
void Doit();
void Getname();
void Printname() {cout << "Hello " << Name << "!" << endl;}
};

void Greeting:oit(){
Getname();
Printname();
}

void Greeting::Getname(){
cout << "What is your name? ";
cin >> Name;
}

int main(){

Greeting Hello;
return 0;
}
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I program this into CSS? green_eyed_goddess CSS Forum 0 08-24-2008 04:44 PM
program that the cpu can execute directly and a program that must be translated? krnkinka CPU Forum 0 08-24-2008 04:20 PM
how to do program in php? vicky PHP Forum 0 08-23-2008 10:04 PM
Spyware program detected 'Tagasaurus Trojan 'in Ccleaner program files? Northman Spyware Forum 0 04-19-2008 09:01 AM
i need a program in php? hireshire PHP Forum 0 01-06-2008 04:05 AM


All times are GMT. The time now is 04:31 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93