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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T14:41:16+00:00 2026-05-17T14:41:16+00:00

I am working on this project just trying to keep up my c++ knowledge.

  • 0

I am working on this project just trying to keep up my c++ knowledge. Anyways, I am getting many, many errors when i try to implement an operator overload. Not sure why.

#include "students.h"
#include <iostream>
#include "Quack.h"

using namespace std;

void main()
{


quack* classmates = new quack;

classmates->pushFront(students("corey", "9081923456", 4.0));

cout << "\noriginal data set -- " << *students;

and this is where i am getting the errors with the operator. Oddly enough if i comment out the overloaded operator and leave it in students.cpp it compiles find.

#ifndef STUDENTS_H
#define STUDENTS_H
#include <iostream>

class students
{
      // causing errors
friend ostream& operator << (ostream& out,const students& student);

public:
students();
students(char * name, char* oitId, float gpa);
students(const students& student); // copy constructor;
 ~students();
const students& operator=(const students& student);

void getName(char* name) const;
void getoitId(char* oitId) const;
float getGpa(void) const;

void setName(char* name);
void setoitId(char* oitId);
void setGpa(float gpa);


private:
char*    name;
char*    oitId;
float    gpa;

};

#endif

}

and, causes errors alo. But not by itself..

#include "students.h"
#include <iostream>
#include <iomanip>

using namespace std;
#pragma warning(disable:4996)       

private:
char* name;
char* oitId;
float gpa;

students::students(): name(NULL), oitId(NULL), gpa(0)
{
}


students::students(char *name, char *oitId, float gpa): name(NULL), oitId(NULL), gpa(0)
{
setName(name);
setoitId(oitId);

}

students::~students()
{

if(name)
delete[] name;
if(oitId)
delete[] oitId;

}




const students& students::operator=(const students& student)
{

//if it is a self copy, don't do anything
if(this == &student)
    return *this;
//make current object *this a copy of the passed in student
else
{
    setName(student.name);
    setoitId(student.oitId);
    //setGpa(student.gpa);
    return *this;
}

}


void students::setName(char *name)
{

//release the exisisting memory if there is any
if(this->name)
delete [] this->name;

//set new name
this->name = new char[strlen(name)+1];
strcpy(this->name, name);

}

void students::setoitId(char *oitId)
{

if(this->oitId)
delete [] this->oitId;

//set new Id
this->oitId = new char[strlen(oitId)+1];
strcpy(this->oitId, oitId);

}

ostream& operator<< (ostream& out, const students& student)
{

//out << setw(20) << student.name
    //<< setw(15) << student.pccId
    //<< setw(8) << fixed << setprecision(2) << student.gpa;
return out;
}

here is the errors i get

syntax error : missing ‘;’ before ‘&’
: error C2433: ‘ostream’ : ‘friend’ not permitted on data declarations
error C4430: missing type specifier – int assumed. Note: C++ does not support default-int
error C2061: syntax error : identifier ‘ostream’
error C4430: missing type specifier – int assumed. Note: C++ does not support default-int
error C2805: binary ‘operator <<‘ has too few parameters
1>Generating Code…
1>Compiling…
1>students.cpp

my eyes are burning and i cant figure out why its unhappy with the overloaded operator..

  • 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-17T14:41:16+00:00Added an answer on May 17, 2026 at 2:41 pm

    You are using ostream without qualifying it with namespace std::

    The compiler errors/warnings are vaguely telling you that it has encountered a type that has not been declared yet.

    friend std::ostream& operator << (std::ostream& out,const students& student);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to keep the database tables for a project I'm working on nice
Its my first time working on a project in C. im just trying to
basically im just trying to finish off a project im working on, having a
So this was working on this project a few months ago. I'm using Google
I am working on this project where I wish to classify the general mood
I'm working on this project where the client has a virtual server setup. I
I'm working on this project and the customer wants it to integrate with a
I'm working on this project and I have to open a new browser tab.
I am working on this project where I need to read in a lot
I've been working on this project for about two weeks now. I don't understand

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.