[linux-audio-dev] A C++ question

Nick Tsocanos nicktsocanos at charter.net
Thu Apr 17 23:37:01 UTC 2003


> 
> You don't give much detail, but here my guess:
> 
The problem is I have not fully  understand why it happens. 

One, at runtime, it seems to get smashed, and when I execute a virtual
function it goes off somewhere else and crashes. When I fix my program
some more, and make them virtual again, it compiles and runs fine. My
only guess is that I smashed the class somehow, but the smash is
baffling, because the program works fine, it just the when I execute a
virtually defined function in the class when it fails. 

class BadFoo()
{
  virtual void ThisFooWillDie() { printf("Fooey!"); }

  void naughtyFunctionThatIsBeingWorkedOn() {
	printf("I will do something heinous and sinister to foo but
		only to Foo but it will not be obvious what it is.");
  }
};

BadFoo fooWillBlowUp;

fooWillBlowUp.naughtyFunctionThatIsbEingWorkedOn();
fooWillBlowUp.ThisFooWillDie();

CORE DUMP
GAME OVER


Another, is when I am linking, it complains about the vtable and won't
compile. This error leaves me baffled because usually the class compiled
and ran before without any problems, and I didn't change it at all.

class thisFooWillNotCompile
{
public:

	virtual void thisFooMakesMeAngry() = 0;
};

class thisFooIsNoGood : public thisFooWillNotCompile
{
public:

   void thisFooMakesMeAngry() { printf("I will not link I will say
vtable blah blah blah and die..\n"); }
};


Sorry I am vague but, if I knew why this was happening, I would be an
advanced C++ programmer.One of them appears to be an error in my code,
but the way it manifests itself is weird. The other is a compiler
problem that I just do not know why it happens and honestly it shouldn't
because the code worked fine before and is correct syntax, but it won't
link. It says something about the vtable but I can't remember now what
it said. It happened a week ago.







More information about the Linux-audio-dev mailing list