home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!wupost!gumby!destroyer!ubc-cs!unixg.ubc.ca!kakwa.ucs.ualberta.ca!access.usask.ca!skorpio!srikant
- From: srikant@skorpio.usask.ca (Srikant Subramaniam)
- Subject: Problems with constructor in C++
- Message-ID: <1992Sep14.225041.15692@access.usask.ca>
- Sender: srikant@skorpio (Srikant Subramaniam)
- Nntp-Posting-Host: skorpio.usask.ca
- Organization: University of Saskatchewan, Saskatoon, Canada
- Date: Mon, 14 Sep 1992 22:50:41 GMT
- Lines: 48
-
- Hello Netters:
-
- I have a rather peculiar problem with constructors in C++. In the code
- fragment below, the constructor for AtomicInt is not executed at all.
-
- File chore.h
- ------------
-
- Class Chore : public DLINK {
-
- ......
- .......
-
- AtomicInt numworkers;
- public: Chore ( .......) {
-
- }
- } // Class Chore
-
- File atomic_int.h
- ------------------
-
- Class AtomicInt {
-
- ...........
-
- AtomicInt() { .......}
- AtomicInt(int x) { ......}
- AtomicInt(AtomicInt& x) { .......}
- }
-
- When the code is executed, the constructor for AtomicInt doesn't get executed
- at all. My understanding of C++ was that when the initialization is done as
- in AtomicInt numworkers, the constructor is automatically executed. I hope I'm
- not wrong :-(
-
- Could somebody out in net.land clarify this ?
-
- -----
- |\/\/\/| Srikant Subramaniam.
- | | srikant@cs.usask.ca
- | |
- | | Disclaimer: This is not what really I look like.
- | (o)(o) Disclaimer: I didn't do it, nobody saw me do it,
- C _) can't prove anything.
- | ,___|
- | /
- /---\
-