Qbasicnews.com
June 26, 2019, 07:12:22 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: C++ problem  (Read 2894 times)
wallace
Wandering Guru
***
Posts: 368



WWW
« on: April 07, 2006, 11:52:03 AM »

Code:
#include "Wrapper.h"
int Compare(int, int);

int main(){
  //stuff
}

int Compare(int x, int y){
  if (x == y)
      return 0
  else
      return 1
}


Wrapper inherites from object where Compare is declared as pure virtual.  In Wrapper.cpp I have an error here:

Code:
template <class datatype>
int Wrapper<datatype>::CompareTo (Object const & obj) const { Wrapper<datatype> const & arg = dynamic_cast<Wrapper<datatype> const &> (obj);
// comparing wrapped datatype, not objects, so need to cast
return :: Compare (datum, arg.datum);
// :: Compare(...) is global and define in the driver program
}


The error is on the return command saying that Compare has not been declared.  What's going on?
Logged

f you play a Microsoft CD backwards you can hear demonic voices.  The scary part is that if you play it forwards it installs Windows.
thegrogen
Ancient QBer
****
Posts: 444



« Reply #1 on: April 07, 2006, 05:49:35 PM »

Did you remember to provide a function prototype BEFORE the template stuff?
Logged

.14159265358979323846264338327950288419716939937510582709445
Glarplesnarkleflibbertygibbertygarbethparkentalelelangathaffendoinkadonkeydingdonkaspamahedron.
wallace
Wandering Guru
***
Posts: 368



WWW
« Reply #2 on: April 07, 2006, 07:43:16 PM »

The second line of code.
Logged

f you play a Microsoft CD backwards you can hear demonic voices.  The scary part is that if you play it forwards it installs Windows.
Ryan
Wandering Guru
***
Posts: 338



WWW
« Reply #3 on: April 07, 2006, 08:46:47 PM »

Exactly.. that's after the include.  Does this not matter in C++?
Logged
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #4 on: April 07, 2006, 10:37:04 PM »

It should. An include just pastes code. So, technically, that prototype is after the template definition.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
wallace
Wandering Guru
***
Posts: 368



WWW
« Reply #5 on: April 09, 2006, 11:21:58 AM »

oh *smacks self*
Logged

f you play a Microsoft CD backwards you can hear demonic voices.  The scary part is that if you play it forwards it installs Windows.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!