View Single Post
Join Date: Aug 2008
Posts: 206
Reputation: grumpier has a spectacular aura about grumpier has a spectacular aura about 
Solved Threads: 31
grumpier grumpier is offline Offline
Posting Whiz in Training

Re: Inheritance, and code not running

 
0
  #2
Dec 4th, 2008
Your problem is actually the first four lines of the main() function. I've added comments to the code that are related to problems on each line.
  1. void main() // main should return int, not void
  2. {
  3. sLink* pChainLink; // uninitialised pointer
  4. sLink ChainLinkNo1 (pChainLink, 1); // undefined behaviour: accessing value of uninitialised pointer
  5. sLink ChainLinkNo2 (ChainLinkNo1, 2); // compiler error: ChainLinkNo1 not a pointer, sLink's constructor expects one
  6. sLink ChainLinkNo3 (ChainLinkNo2, 3); // compiler error: ChainLinkNo2 not a pointer, sLink's constructor expects one
The only reason the compiler is complaining about the line you have highlighted is that it is the only constructor that might be invoked by your code, but you've provided the wrong type of argument.
Last edited by grumpier; Dec 4th, 2008 at 11:36 pm.
Reply With Quote