| | |
pointersss...
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2008
Posts: 1
Reputation:
Solved Threads: 0
hello, Im kinda stuck on how to initialize the class inside the main. Or what to write instead of the ??? inside the main.
Thank you in advance...
Thank you in advance...
C++ Syntax (Toggle Plain Text)
//********************************************************** // Work In Progress // Author Armen Babakanian // A complete set of examples to use reference and pointer issues // in related to functions and classes //********************************************************** #include <iostream> #include <string> using namespace std; class Job { public: Job(string compName, string titl, double sal) : companyName(compName), title(titl), salary(sal){}; Job(){}; string& getCompanyName() {return companyName;}; string& getTitle() {return title;}; double getSalary() {return salary;}; void setCompanyName(string name) {companyName = name;}; void setTitleName(string name) {title = name;}; void setSalery(double name) {salary = name;}; private: string companyName; string title; double salary; }; //*********************************************************8 class person { public: person(string name, string last, string compName, string title, double sal, Job& job) : m_name(name), m_last(last), m_firstJob(job){}; int getAge(){return m_age;}; string getName(){return m_name;}; string getLast(){return m_last;}; void setAge(int age) {m_age = age;}; Job& get1stJob(){ return m_firstJob;}; //------------------------------------ Job* get2ndJob(){ return m_secondJob;}; private: string m_name; string m_last; int m_age; Job& m_firstJob; Job* m_secondJob; }; //*********************************************************8 void main() { //Job first; person RafaelB("Rafael","BakerMan", "Starbucks", "maneger", 8.50,Job first); RafaelB.setAge(22); cout << RafaelB.getName() << " --" << RafaelB.getLast() << " --" << RafaelB.getAge() << endl; cout << RafaelB.get1stJob().getCompanyName() << " --" << RafaelB.get1stJob().getTitle() << " --" << RafaelB.get1stJob().getSalary() << endl; }
•
•
Join Date: Jun 2007
Posts: 275
Reputation:
Solved Threads: 45
•
•
•
•
//Job first;
person RafaelB("Rafael","BakerMan", "Starbucks", "maneger", 8.50,Job first);
C++ Syntax (Toggle Plain Text)
Job first; person RafaelB("Rafael","BakerMan", "Starbucks", "maneger", 8.50,first);
You might want to run a spell checker on your code also
![]() |
Other Threads in the C++ Forum
- Previous Thread: Plz Help Urgently In My Program
- Next Thread: Writing a program with an array that averages 10 numbers
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator getline graph homeworkhelper iamthwee ifstream image input int integer java lib list loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings struct template text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






