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

  • Home
  • SEARCH
  • 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 4022480
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:28:49+00:00 2026-05-20T10:28:49+00:00

Pretty new to C++, I have been following the intermediate tutorials at 3DBuzz.com, and

  • 0

Pretty new to C++, I have been following the intermediate tutorials at 3DBuzz.com, and trying to experiment with their tasks.

Current tutorial is on classes: http://www.3dbuzz.com/vbforum/sv_showvideo.php?v=37

I am trying to overload the &operator << to output my ‘Point’ as a stream when I want. The relevant part of the video starts at 39:00.

As far as I can tell my code is syntactically identical (though I am new so I’m probably missing something) but I get the error:

1>c:\users\jack\documents\visual studio 2010\projects\myfirstgame\myfirstgame\main.cpp(88): error C2146: syntax error : missing ‘;’ before identifier ‘myPoint

I realise that I declare the instance Point &myPoint in the operator overload function.. but I don’t know where else I could do it so the compiler knows what it is.. if that makes sense.

Any help is appreciated! Thanks

#include <iostream>
#include <cmath>

using namespace std;

class Point
{
public:
Point(float f_x = 0.0, float f_y = 0.0, float f_z = 0.0);

~Point();

void SetXYZ(float X, float Y, float Z);
void SetX(float X);
void SetY(float Y);
void SetZ(float Z);

void GetXYZ(float &X, float &Y, float &Z);
float GetX();
float GetY();
float GetZ();
private:

float x, y, z;

protected:

};

Point::Point(float f_x, float f_y, float f_z)
{
cout << "Constructor with ARGUMENTS!" << endl;

x = f_x;
y = f_y;
z = f_z;
}

void Point::GetXYZ(float &X, float &Y, float &Z)
{
X = GetX();
Y = GetY();
Z = GetZ();
}
float Point::GetX()
{
return x;
}

float Point::GetY()
 {
return y;
 }

float Point::GetZ()
{
return z;
}

void Point::SetXYZ(float X,float Y, float Z)
{
SetX(X);
SetY(Y);
SetZ(Z);
}
void Point::SetX(float X)
{
x = X;
}

void Point::SetY(float Y)
{
y = Y;
}

void Point::SetZ(float Z)
{
z = Z;
}

Point::~Point()
{
cout << "We're in the destructor" << endl;
}

 ostream &operator <<(ostream &stream, Point &myPoint)
{
stream << myPoint.GetX() << " " << myPoint.GetY() << " " myPoint.GetZ();
return stream;
}

void main()
{
float x, y, z; //Declaring floats for use in GetXYZ()

Point myLocation (1,2,-1); //Creating instance and using Point(...) function
cout << myLocation.GetX() << myLocation.GetY() << myLocation.GetZ() <<endl; // Getting xyz values and printing

myLocation.SetXYZ(2,3,-4); //Testing SetXYZ function
cout << myLocation.GetX() << myLocation.GetY() << myLocation.GetZ() <<endl; // Getting xyz values and printing


myLocation.GetXYZ(x, y, z);
cout << x << " " << y << " " << z << endl;

cout << myLocation;


    system("PAUSE");
}

EDIT: Unbelievable response! Love this site already. Thanks everyone who spotted this ^^

  • 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-20T10:28:49+00:00Added an answer on May 20, 2026 at 10:28 am

    You are missing << in :

    stream << myPoint.GetX() << " " << myPoint.GetY() << " " myPoint.GetZ();
                                                           ^^
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm pretty new to Android app development, and I've been playing around with swipe
I'm pretty new to lisp; I was wondering if anyone here could help me
I have been browsing some php source code and need to know how the
I've started a new job this week and am trying to get my head
I have an approach in mind for an image viewer in a web app,
I find my edit actions in CakePHP controllers get messy pretty quickly, and I'd
I am using the Specification pattern, and have a working implementation (taken from the
Forgive me if I've got my terminology wrong; I am still quite new to
Correction: I messed up with the concept of pointer address and the address the
I'm transitioning to using OOP for all my projects, historically everything I've built has

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.