|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
i also got the same warning i will give u the code
#include<iostream> #include<string> using namespace std; class CEmployee { public: CEmployee(string name = "No Name", string id = "000-00-0000", double salary = 0) : _name(name), _id(id) { _salary = salary; } string getName() const {return _name;} void setName(string name) {_name = name;} string getid() const {return _id;} void setid(string id) {_id = id;} double getSalary() const {return _salary;} void setSalary(double salary) {_salary = salary;} void promote(double salary) const {_salary = salary;} private: string _name; string _id; mutable double _salary; }; int main() { CEmployee employee("Naren", "001-338-423", 23456) ; fprintf(stderr, "--Name() Id(%s) Salary(%f)-------\n", employee.getid(), employee.getSalary()) ; } :!g++ % mutable.cc: In function `int main()': mutable.cc:34: warning: cannot pass objects of non-POD type `struct std::string' through `...'; call will abort at runtime |
|
|||
|
Quote:
The %s argument requires a c-styled string, but you've passed it an actual std::string object. Try: C++ Code:
|
| Sponsored Links |
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| XML-JSP content Type problem | hbmehta15 | JavaScript and CSS | 3 | 06-19-2007 04:39 AM |
| Unbound type constructor | snowfall | General Programming | 0 | 04-25-2007 04:01 PM |
| Type Casting | clookid | PHP Tutorials | 1 | 01-11-2007 09:32 PM |
| Java:Tutorial - Adding more objects to your window | John | Java Tutorials | 0 | 01-11-2007 03:09 PM |
| Objects | Nightracer | General Programming | 8 | 07-28-2006 09:02 PM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2684.34 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |
Goal: 100,000 Posts
Complete: 97%