Cannot Inherit from a class

I'm trying to inherit from a parent class and I get the Error that the name specified is not a class or struct.

The code is as follows

WeirdBot.h
1
2
3
4
5
6
7
8
9
10
11
12
#include <vcclr.h>   
#include <VBot.h>

using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;

class WeirdBot : public VBot
{
public:
	WeirdBot( int startX, int startY, Panel ^ drawingPanel ) : 
      x(startX), y(startY), panel(drawingPanel), energy(100), image(NULL) { }


VBot.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#pragma once

#include <vcclr.h>   

using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;

class VBot
{
public:

   VBot( int startX, int startY, Panel ^ drawingPanel ) : 
      x(startX), y(startY), panel(drawingPanel), energy(100), image(NULL) { }

   virtual ~VBot() { }

   virtual void Move() = 0;

   virtual int EnergyToFightWith() = 0;

   bool IsDead() const { return energy <= 0; }

   virtual void Show();

   bool CollidedWith ( VBot * b ) const;

   void DoBattleWith ( VBot * b );
   
protected:
      int x, y;                   
      gcroot<Drawing::Bitmap ^> image;
      gcroot<Panel ^> panel;         
      int energy;                    
};
Can you please tell where are getting error as i understood error can be in the constructor of weirdBot .as it should be like
WeirdBot( int startX, int startY, Panel ^ drawingPanel ) : VBot( startX,StartY,drawingPanel );
Last edited on
Yeah I still have to fix that, but the error is in WeirdBot.h on this line

class WeirdBot : public VBot

It's saying VBot is not a class or struct
Firstly, that looks like C sharp, not C++. While there are similarities between the languages, there are also important differences, so you may get more appropriate help from a C# forum.

As a C++ developer, I can't see anything immediately that would prevent you inheriting from VBot. Is it possible that there's an alternative definition of the symbol VBot somewhere in a header file, that's hiding the class definition?
Topic archived. No new replies allowed.