Closed Thread
Results 1 to 5 of 5

Thread: G++ Error: cannot pass objects of non-POD type

  1. #1
    Ronin is offline Programming Professional
    Join Date
    Apr 2006
    Posts
    309
    Rep Power
    24

    G++ Error: cannot pass objects of non-POD type

    What does this error mean??

    cannot pass objects of non-POD type

    I'm using G++

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    orbital_fox's Avatar
    orbital_fox is offline Newbie
    Join Date
    Sep 2006
    Posts
    26
    Rep Power
    0
    POD, in C++ stands for Plain Old Data.

    While u have not posted the code you have, i cannot tell your excact error, but since it says something about objects passed on and POD, i assume u are using some old data type from C, and trying to do some sort of operation that only objects in C++ can handle..
    Artificial Intelligence and Robotics egnineer
    http://fox.zsuatt.com/

  4. #3
    Paradine is offline Learning Programmer
    Join Date
    Oct 2006
    Posts
    48
    Rep Power
    0
    Can you post your code?

  5. #4
    anupm is offline Newbie
    Join Date
    Sep 2007
    Posts
    1
    Rep Power
    0
    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

  6. #5
    skoe is offline Newbie
    Join Date
    Oct 2007
    Posts
    2
    Rep Power
    0

    Thumbs up

    Quote Originally Posted by anupm View Post
    fprintf(stderr, "--Name() Id(%s) Salary(%f)-------\n", employee.getid(), employee.getSalary()) ;
    Hi,

    The %s argument requires a c-styled string, but you've passed it an actual std::string object.
    Try:
    [HIGHLIGHT="C++"]fprintf(stderr, "--Name() Id(%s) Salary(%f)-------\n", employee.getid().c_str(), employee.getSalary());[/HIGHLIGHT]

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Java Incompatible Type Error
    By Pwincy Priya in forum Java Help
    Replies: 2
    Last Post: 11-17-2010, 02:56 AM
  2. Replies: 5
    Last Post: 06-20-2010, 10:52 PM
  3. Replies: 2
    Last Post: 05-31-2010, 02:32 PM
  4. 'Could not convert variant of type (String) into type (Double)'
    By Ilikestring in forum Pascal and Delphi
    Replies: 3
    Last Post: 03-26-2010, 05:35 PM
  5. This error driving me crazy! "Ordinal Type required"
    By 2710 in forum Pascal and Delphi
    Replies: 2
    Last Post: 11-12-2009, 11:00 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts