Thread View: comp.std.c++
1 messages
1 total messages
Started by Loon P. van
Thu, 23 Nov 1995 15:32
Constructor with variable number of arguments
Author: 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. ]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads