[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: cannot pass objects of non-POD type
From: |
Ron Natalie |
Subject: |
Re: cannot pass objects of non-POD type |
Date: |
Wed, 13 Oct 2004 10:04:54 -0400 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20040913 Thunderbird/0.8 Mnenhy/0.6.0.104 |
Vijay wrote:
[oracle@sahyagiri test]$ g++ sam.cpp
sam.cpp: In function `int main()':
sam.cpp:17: warning: cannot pass objects of non-POD
type `struct std::string'
through `...'; call will abort at runtime
The compiler is giving you a big hint here. You can not
pass arguments of non-POD type to VARARG'd functions.
std::string is a non-POD type.
Varargs has no clue about how to deal with non-POD types
(mostly because it doesn't know about the special
construction/copy/destruction sematics inherit in passing
them to subroutines).
I always theorized that an operator... function should
be invoked to convert to something that ... could handle
for classes. This would be in line with out ... args work
in general (there is a conversion, like integer promotion
etc... that makes things work in general)>