Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7180265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:18:41+00:00 2026-05-28T17:18:41+00:00

I have created a functional OOP program that uses a bunch of classes, and

  • 0

I have created a functional OOP program that uses a bunch of classes, and I am getting a bunch of errors that don’t make sense. I am working on a Windows VC++ 2008 project, and at the start I tried to have different implementation, and header files. when I tried to for example make a
object1.cpp

#ifndef Object1_cpp
#define Object1_cpp

#include "Object1.h"

Object1::Object1(){
   ...
}
Object1::~Object1(){
   ...
}
....
#endif

object1.h

#ifndef Object1_H
#define Object1_h
class Object1{
public: Object1();
public: ~Object1(); // line 39 of object1.h
...
};
#endif

Main.cpp

#include "object1.cpp"

sometimes this returns errors of

1>c:...\object1.h(39) : error C2059: syntax error : '('
1>c:...\object1.h(39) : error C2238: unexpected token(s) preceding ';'

and since it is not complaining about the constructor the only thing that comes to mind would be the ‘~’ indicating the destructor. when I take the .h out of the picture changing the .cpp to be

#ifndef Object1_H
#define Object1_h
class Object1{
public: Object1::Object1();
public: Object1::~Object1();
...
};
#endif

or

#ifndef Object1_H
#define Object1_h
class Object1{
public: Object1();
public: ~Object1();
...
};
#endif

it compiles fine. I don’t understand it. when I have done something similar in the past on other compilers it works fine, but it doesn’t here.
currently the program is fully functional while I ignore the existence of the .h files, and do everything in the .cpp files. it seems like the compiler throws an issue with the Til-de operator denoting the destructor. this is just one example of the problem, and it occurs in all of my classes when I try to split up the implementation, and forward references.

found solution. apparently one of my team mates used the same #define in one of his files (because it made sense but wasn’t the name of the file as convention was required)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:18:42+00:00Added an answer on May 28, 2026 at 5:18 pm

    Your include guards are broken:

    #ifndef Object1_H
    #define Object1_h
    

    You have a _H at the end of one and an _h at the end of the other. This causes the include guard not to work.

    Also, you don’t need, and don’t want, include guards in your implementation files. They should never be included by anything anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created some functional categories that I use to show/hide markup elements. However,
I'm writing a program that uses OOP to store student records. At the moment
I have created a function that takes a SQL command and produces output that
I have created a function in PHP that calls a webservice and parses through
I've made a program for my OOP class that does the following: Defines a
I have been trying to make OOP PHP5 code. But I think my attempts
I have some c++ OOP classes (separated files) , and I want to create
I am new to OOP and I have been working on this example but
We currently have a fully functional Gui written created using PyQt. My partner wrote
Currently I have something in lua that is like OOP using tables. TCharacterController =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.