C++ Help

Discussion in 'GR Classic Archive' started by r3m1x, Feb 22, 2009.

  1. r3m1x

    r3m1x Well-Known Member

    Posts:
    2,260
    Likes Received:
    0
    Joined:
    Jun 21, 2005
    Location:
    New York City
    K I got a very basic thing going on, and I can't figure out why it won't work.
    ERROR C2653: 'Ant' : is not a class or namespace name (I understand the error, I just don't understand why it comes up)
    please keep in mind that I'm VERY new to c++, so I know nothing.

    main.cpp
    Code:
    #include "bug.h"
    #include "ant.h"
    
    using namespace std;
    
    void main()
    {
        Bug b = Bug(1,2,3) 
        Ant a = Ant();
    }
    bug.h
    Code:
    #pragma once
    
    class Bug
    {
    private:
        int str, wit, val;
    public:
        Bug(int a, int b, int c);
        ~Bug();
        
    };
    bug.cpp
    Code:
    #include "bug.h"
    
    Bug::Bug(int a, int b, int c)
    {
        str = a;
        wit = b;
        val = c;
    }
    
    Bug::~Bug()
    {
    }
    ant.h
    Code:
    #pragma once
    
    #include "bug.h"
    
    class Ant::public Bug
    {
    public:
        Ant();
        ~Ant();
    };
    ant.cpp (the error is in this one apparently)
    Code:
    #include "ant.h"
    
    Ant::Ant()
    {
        str = 1;
        wit = 1;
        val = 1;
    }
    
    Ant::~Ant()
    {
    }
     

Share This Page