Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VC 6.0 Error

Posted on 2003-03-28
2
Medium Priority
?
234 Views
Last Modified: 2010-04-01
Hello experts,

I was wondering what syntax is used for this overloading function:
//.h
namespace T {
   class S {
      public:
         //...
         friend S operator * (const S&, const S&);
         //...
   };
}

I tried
//.cpp
S T::operator * (const S& Ia, const S& Ib) {}

but instead got an error "missing ; before tag::id." I'm pretty sure all my ';'s are accounted for. Thanks, =)
0
Comment
Question by:n_fortynine
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Accepted Solution

by:
efn earned 200 total points
ID: 8229837
Hi n_fortynine,

You need to get all the Ses qualified as well as the operator keyword.  There are multiple ways to do it.

Inside the namespace T block, you could have:

S operator * (const S& Ia, const S& Ib) {}

Outside the namespace T block, you could have:

T::S T::operator * (const T::S& Ia, const T::S& Ib) {}

Or you could tell the compiler to look for S in namespace T like this:

using T::S;

S T::operator * (const S& Ia, const S& Ib) {}

--efn
0
 
LVL 4

Author Comment

by:n_fortynine
ID: 8229877
Thanks efn. Man, it's embarassingly obvious... =) Why didn't I see that
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question