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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:16:33+00:00 2026-05-20T22:16:33+00:00

getting error: neljastest.cpp: undefined reference to Vector2::Vector2(float, float) neljastest.cpp: #include <cstdlib> #include <iostream> #include

  • 0

getting error: neljastest.cpp: undefined reference to Vector2::Vector2(float, float)

neljastest.cpp:

    #include <cstdlib>
#include <iostream>
#include "../include/Vector2.h"
#include "../include/neljas.h"

using namespace std;

int main (int argc, char* argv[]) {
     Vector2 p1 (1.0, 2.0);
     Vector2 p2 (0.0, 0.0);
     Vector2 p3 (5.0, 2.0);
    return EXIT_SUCCESS;
}

vector2.h:

#ifndef VECTOR2_H
#define VECTOR2_H

#include <iostream>
using std::ostream;

class Vector2 {

public:
    float x;
    float y;

    Vector2();

    Vector2(float nx, float ny);

    float distanceFrom(Vector2 v);


};


ostream& operator << (ostream& valja, Vector2 v);

#endif

vector2.cpp:

    #include "../include/Vector2.h"
#include <cmath>

using namespace std;

Vector2::Vector2() {
    x = 0;
    y = 0;
}

Vector2::Vector2(float nx, float ny) {
    x = nx;
    y = ny;
}

float Vector2::distanceFrom(Vector2 v) {
    return sqrt( (x - v.x)*(x - v.x) + (y - v.y)*(y - v.y) );
}

ostream& operator << (ostream& os, Vector2 v) {
    return os << "(" << v.x << "," << v.y << ")";
}
  • 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-20T22:16:33+00:00Added an answer on May 20, 2026 at 10:16 pm

    C/C++ are case sensitive for headers too.

    It seems that on vector2.cpp and neljastest.cpp you must change the include from:

    #include "../include/Vector2.h"
    

    To:

    #include "../include/vector2.h"
    

    I pasted all your sources on the same folder and successfully compiled them with:

    g++ neljastest.cpp vector2.cpp -o neljastest
    

    Edit:

    Your problem is that the linking process of neljastest.cpp depends on src/vector2.cpp, and you are not doing that on the Makefile

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

Sidebar

Related Questions

getting error 1061: Call to a possibly undefined method stop through a reference with
I getting the error undefined method `update_attributes' for nil:NilClass when using Sinatra with MongoMapper.
I'm getting error while using replace in an update statement in sql server 2008.
I'm getting error using the following code snippet jQuery(document).ready(function() { jQuery.ajax({ url: url, type:
i'm getting error cannot find symbol in netbeans while using the below code for
I am getting #error WINDOWS.H already included. MFC apps must not #include windows.h But
I'm getting error while using php function copy() Warning: copy() [function.copy]: Couldn't resolve host
i am getting error using this syntax this.Page.ClientScript.RegisterStartupScript(typeof(string), Test, alert('<%=Resources.Text.Header_Login%>');); please any suggestion reply
i am getting error : Error 1 The type or namespace name'CreateUser' does not
getting error while try to start service

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.