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

The Archive Base Latest Questions

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

i get 2 linker errors when trying to compile my program which includes these

  • 0

i get 2 linker errors when trying to compile my program which includes these two files (causing the problem, in particular the lines in bold)

and i’m new to C++ so excuse my ignorance.

Assignment1.obj : error LNK2001: unresolved external symbol “public: class Vector __thiscall Vector::operator^(class Vector)” (??TVector@@QAE?AV0@V0@@Z)

1>Assignment1.obj : error LNK2001: unresolved external symbol “class std::basic_ostream > & __cdecl operator<<(class std::basic_ostream > &,class Point)” (??6@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@VPoint@@@Z)

1>c:……\visual studio 2010\Projects\Assignment1\Release\Assignment1.exe : fatal error LNK1120: 2 unresolved externals

point.h file:

#ifndef SS_Point_H
#define SS_Point_H

#include "common.h"

//==================================================================
//  Point Class Definition
//==================================================================

class Point {
friend class Vector;
protected:
 int dimn;            // # coords (1, 2, or 3 max here)
 Error err;           // error indicator
public:
 double x, y, z;      // z=0 for 2D, y=z=0 for 1D

 //----------------------------------------------------------
 // Lots of Constructors (add more as needed)
 Point() { dimn=3; x=y=z=0; err=Enot; }
 // 1D Point
 Point( int a) {
  dimn=1; x=a; y=z=0; err=Enot; }
 Point( double a) {
  dimn=1; x=a; y=z=0; err=Enot; }
 // 2D Point
 Point( int a, int b) {
  dimn=2; x=a; y=b; z=0; err=Enot; }
 Point( double a, double b) {
  dimn=2; x=a; y=b; z=0; err=Enot; }
 // 3D Point
 Point( int a, int b, int c) {
  dimn=3; x=a; y=b; z=c; err=Enot; }
 Point( double a, double b, double c) {
  dimn=3; x=a; y=b; z=c; err=Enot; }
 // n-dim Point
 Point( int n, int a[]);
 Point( int n, double a[]);
 // Destructor
 ~Point() {};

 //----------------------------------------------------------
 // Input/Output streams
 **friend std::istream& operator>> ( std::istream&, Point&);
 friend std::ostream& operator<< ( std::ostream&, Point );**

….}

while point.c file:

#include "point.h"
#include "vector.h"
#include <iostream.h>
//==================================================================
// Point Class Methods
//==================================================================

//------------------------------------------------------------------
// Constructors (add more as needed)
//------------------------------------------------------------------

// n-dim Point
Point::Point( int n, int a[]) {
 x = y = z = 0;
 err = Enot;
 switch (dimn = n) {
 case 3: z = a[2];
 case 2: y = a[1];
 case 1: x = a[0];
  break;
 default:
  err=Edim;
 }
}

Point::Point( int n, double a[]) {
 x = y = z = 0.0;
 err = Enot;
 switch (dimn = n) {
 case 3: z = a[2];
 case 2: y = a[1];
 case 1: x = a[0];
  break;
 default:
  err=Edim;
 }
}

//------------------------------------------------------------------
// IO streams
//------------------------------------------------------------------

// Read input Point format: "(%f)", "(%f, %f)", or "(%f, %f, %f)"


**std::istream& operator>>( std::istream& input, Point& P) {**
     char c;
     input >> c;                // skip '('
     input >> P.x;
     input >> c;                
     if (c == ')') {
      P.setdim(1);       // 1D coord
      return input;
     }
     // else                    // skip ','
     input >> P.y;
     input >> c;
     if (c == ')') {
      P.setdim(2);       // 2D coord
      return input;
     }
     // else                    // skip ','
     input >> P.z;
     P.setdim(3);               // 3D coord
     input >> c;                // skip ')'
     return input;
    }

// Write output Point in format: "(%f)", "(%f, %f)", or "(%f, %f, %f)"
**std::ostream& operator<<( std::ostream& output, Point P) {**
 switch (P.dim()) {
 case 1:
  output << "(" << P.x << ")";
  break;
 case 2:
  output << "(" << P.x << ", " << P.y << ")";
  break;
 case 3:
  output << "(" << P.x << ", " << P.y << ", " << P.z << ")";
  break;
 default:
  output << "Error: P.dim = " << P.dim();
 }
 return output;
}

…..
…..
…..
}

  • 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-17T17:58:19+00:00Added an answer on May 17, 2026 at 5:58 pm

    Its hard from the information given to see the problem; you have C++ code in a .c file, but presumably your compiler would complain if you hadn’t got it to recognize that. To avoid doubt, rename your point.c file point.cpp.

    Generally, its a good idea to use forward declarations of things you want to be friends; this ensures you are befriending some top-level function and not some inner function (particularly regards to friend classes).

    // forward declarations
    class Point;
    std::istream& operator>> ( std::istream&, Point&);
    std::ostream& operator<< ( std::ostream&, Point );
    
    // point class
    class Point {
       ...
       friend std::istream& operator>> ( std::istream&, Point&);
       friend std::ostream& operator<< ( std::ostream&, Point );
       ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to compile an SFML program I've writting in Visual C++ 2010. It
I am trying to get OpenGL and Glut running on Eclipse Linux FC13. After
When compiling a program containing this particular function, /* * Function read_integer * *
I'm trying to compile ZeroMQ C binding in order to be able to use
I am trying to accomplish much the same thing as is being done here
I'm on Windows XP2 32-bit machine. I'm trying to install MPICH2 & mpi4py. I've
I'm trying to set up my Netbeans IDE so that it is capable of
I am trying to create a shared library on Windows. I am able to
I am trying to develop a project in C (on Dev-Cpp IDE) using SQLite
I don't have any significant experience with C++ but recently had to be involved

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.