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

The Archive Base Latest Questions

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

I am writing a small matrix library in C++ for matrix operations. However, my

  • 0

I am writing a small matrix library in C++ for matrix operations. However, my compiler complains, where before it did not. This code was left on a shelf for six months and in between I upgraded my computer from Debian 4.0 (Etch) to Debian 5.0 (Lenny) (g++ (Debian 4.3.2-1.1) 4.3.2). However, I have the same problem on a Ubuntu system with the same g++.

Here is the relevant part of my matrix class:

namespace Math {     class Matrix     {     public:          [...]          friend std::ostream& operator<< (std::ostream& stream, const Matrix& matrix);     } } 

And the "implementation":

using namespace Math;  std::ostream& Matrix::operator <<(std::ostream& stream, const Matrix& matrix) {      [...]  } 

This is the error given by the compiler:

matrix.cpp:459: error: ‘std::ostream& Math::Matrix::operator<<(std::ostream&, const Math::Matrix&)’ must take exactly one argument

I’m a bit confused by this error, but then again my C++ has gotten a bit rusty after doing lots of Java those six months. 🙂

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

    You have declared your function as friend. It’s not a member of the class. You should remove Matrix:: from the implementation. friend means that the specified function (which is not a member of the class) can access private member variables. The way you implemented the function is like an instance method for Matrix class which is wrong.

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

Sidebar

Related Questions

I'm writing small XMPP server using boost::asio and I want to unit-test my code.
I am new to network programming, and have been learning this by writing small
I am writing a program in C++ which uses the CLAPACK ATLAS library. However,
I'm writing code that uses a large matrix where the elements are a user
I'm writing small php extension and have problem when building it. The code: PHP_RINIT_FUNCTION(pstat)
I'm currenty writing small application for image processing. However I have a big problem
I am writing small app, using Play Framework 2.0 which uses Ebean as ORM.
I have an application where I am reading and writing small blocks of data
I'm trying to practice my F# by writing small console scripts in F# in
Coming from a PHP background, I'm used to writing small functions that return a

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.