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 6669881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:12:12+00:00 2026-05-26T03:12:12+00:00

i have Point3D class in my project. to create an object of Point3D i

  • 0

i have Point3D class in my project.
to create an object of Point3D i have added a cpp file & a header file as follows:
CreatePoint.h

#include "stdafx.h"
#pragma once
#include "Point3D.h"

//*******************************************************************
int counter = 0;
int size = 50;
Point3D **point;

//*******************************************************************
void create_array(int);//this will be called in main & pass 50//this is the method to             create an array of pointers to Point3D

//*******************************************************************
void resize();//this increases the size of array if size - 5 elements are filled &     increases size by 25

//*******************************************************************
Point3D *get_point(int);//this returns the pointer according to the index

//*******************************************************************
int get_index(Point3D *);//this returns the index of a point

//*******************************************************************
void move_point(int, int);//this interchanges the memory locations of 2 points

//*******************************************************************
void del_point(Point3D *);//this makes NULL value to the passed point

//*******************************************************************
void destruct_point();//this is called when the program ends by me

& the cpp file is:

#include "stdafx.h"
#include "CreatePoint.h"

//*******************************************************************
void create_array(int s)
{
point = new Point3D *[s];
for (int i = 0; i<s; i++)
{
    point[i] = NULL;
}
}

//*******************************************************************
void resize()
{
Point3D **copy = new Point3D *[size];
for(int i = 0; i<size; i++)
{
    copy[i] = point[i];
}

delete [] point;

size += 25;
create_array(size);

for(int i = 0; i<(size - 25); i++)
{
    point[i] = copy[i];
}

delete [] copy;
}

//*******************************************************************
Point3D *get_point(int i)
{
if((size - counter) == 5)
    resize();
return point[i];
}

//*******************************************************************
int get_index(Point3D *p)
{
for(int i = 0; i<size; i++)
{
    if(point[i] == p)
        return i;
}
return -1;
}

//*******************************************************************
void move_point(int a, int b)
{
Point3D *apt = get_point(a);
Point3D *bpt = get_point(b);

Point3D *t = new Point3D;
t = apt;
apt = bpt;
bpt = t;

delete t;
}

//*******************************************************************
void del_point(Point3D *p)
{
int d = get_index(p);
move_point(d, counter - 1);
point[counter - 1] = NULL;
}

//*******************************************************************
void destruct_point()
{
delete [] point;
point = NULL;
}

i am getting some linking errors:

stdafx.obj : error LNK2005: "class Point3D * * point" (?point@@3PAPAVPoint3D@@A)     already defined in CreatePoint.obj
1>stdafx.obj : error LNK2005: "int counter" (?counter@@3HA) already defined in     CreatePoint.obj
1>stdafx.obj : error LNK2005: "int size" (?size@@3HA) already defined in CreatePoint.obj
1>C:\Documents and Settings\SUMIT & AMIT\my documents\visual studio     2010\Projects\Maths\Debug\Maths.exe : fatal error LNK1169: one or more multiply defined     symbols found

can anybody please help me!!!
also, any suggestions on the code will be appreciated 🙂
THANKS A LOT FOR READING MY POST

  • 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-26T03:12:12+00:00Added an answer on May 26, 2026 at 3:12 am

    In header file use extern when declaring the variables, as:

    //CreatePoint.h
    extern int counter;       //it is only a declaration
    extern int size;          //it is only a declaration
    extern Point3D **point;   //it is only a declaration
    

    And in the source file, define and initialize them as:

    //CreatePoint.cpp
    
    #include "CreatePoint.h"
    
    int counter = 0;   //it is the definition
    int size = 50;     //it is the definition
    Point3D **point;   //it is the definition
    

    You get multiple definitions error, because you include CreatePoint.h more than one .cpp file which defines the same variables more than once. Using extern in header file, avoids this, because it doesn’t define them, it simply declares them, while the actual definition goes in the .cpp file.

    The keyword extern tells the compiler to look for the definition elsewhere. The extern statements in the header are only declaration of the variables.

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

Sidebar

Related Questions

I have the code: class Point3D{ protected: float x; float y; float z; public:
Case One Say you have a little class: class Point3D { private: float x,y,z;
I have the code: class Vector3D : public Vector{ protected: Point3D * start; Point3D
I have a Point2D class as follows: class Point2D{ int x; int y; public:
So, I have a grad class on artificial intelligence and our final project was
I have a apple named WelcomeApplet in the following directory: C:\project\applets\WelcomeApplet.class And I have
I have a class: class Point3D : public Point{ protected: float x; float y;
In a non-boost project, I have a class which uses a timer based on
I have these two functions (with Point2D & LineVector (has 2 Point2D member variables)
In my view, I have: <UserControl x:Class ... MouseDown=UserControl_MouseDown> <Viewport3D Name=Viewport Grid.Column=0> ... </Viewport3D

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.