Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"Because of this forum, I continue to WOW! my clients!"

Geography

Where in the world do Tek-Tips members come from?
benaam (Programmer)
31 Jan 01 17:34
I have the follwing class defined in X.cpp

class X {
  public:
  static bool bl_PropFile;

  void static writeToFile() {
     if(bl_PropFile == true) {
           // do something
     } else if(bl_PropFile == false) {
           // do something
     }
     }
};
bool MonitorCode::bl_PropFile;

Then I have another file called Y.cpp as shown below:

#include <iostream>
#include<stdio.h>
#include "X.cpp"

void main(void) {
// I call the static method of X here
         X::writeToFile();
}

both the files are compiling fine. But when I am building
them I am getting the following error:

X.obj : error LNK2005: "public: static bool X::bl_PropFile" (?bl_PropFile@X@@2_NA) already defined in Log.obj


What cab be the problem?

2ffat (Programmer)
1 Feb 01 6:38
It looks like class X has already been defined in another file (Log). You either have to change the name of the class in X.cpp or define a namespace.

James P. Cottingham
www.ivcusa.com

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close