Article View: comp.std.c++
Article #2721Constructor with variable number of arguments
From: Loon P. van
Date: Thu, 23 Nov 1995 15:32
Date: Thu, 23 Nov 1995 15:32
52 lines
1961 bytes
1961 bytes
Hello everyone,
I have a vector class, representing a vector of type int.
class vector{
int i_dim;
int *v;
public:
// ...
vector(int x);
// ...
vector operator+(vector a);
vector operator*(vector a);
};
I would like to be able to have a constructor with a variable number of arguments,
so that I can do something like:
f(){
vector a(4)=vector(4,0,1,2,3);
vector b(5)=vector(5,0,1,2,3,4);
}
The standard states (if I read it right) that something alike can be done with the use
of an ellipsis function declaration and the use of functions from <stdarg.h>.
However it also state that that is NOT guaranteed to work.
Any suggestions how I can do this?
Greetings from Paul
--
: standard-disclaimer ." All my opinions are strictly my own" ; smudge \ ;)
--> ( vanloonp@iclab.ce.philips.nl)
.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*
^ [] Paul van Loon .-. .-. v
^ [] [] ___\/___ v
^ [] Bought by the Lamb, ~~~~~~~~ v
^ [] freed by the Word v
*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<VANLOONP.95Nov23162536@server9>Path:
arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamageShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage From: vanloonp@mpn.cp.philips.com (Loon P. van) Newsgroups: comp.std.c++ Subject: Constructor with variable number of arguments Date: 23 Nov 1995 15:32:42 GMT Organization: Philips Electronics BV. Approved: clamage@eng.sun.com (comp.std.c++) Distribution: world Message-ID: <VANLOONP.95Nov23162536@server9> NNTP-Posting-Host: taumet.eng.sun.com Content-Type: text X-Nntp-Posting-Host: ic2.seri.philips.nl Content-Length: 1180 Originator: clamage@taumet