Thread: operator problemz w/namespace

  1. #1
    Registered User minime6696's Avatar
    Join Date
    Aug 2001
    Posts
    267

    Exclamation operator problemz w/namespace

    namespace ops
    {
    fop_base_class operator , (int s,int u)
    {
    printf("%i , %i",s,u);
    }
    };

    It gives me this error:
    (im using MSVC)

    D:\programming dump\fop.cpp(5) : error C2803: 'operator ,' must have at least one formal parameter of class type

    Can someone help... ive tried a lot of things... cant figure it out!

    SPH

  2. #2
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    You can't overload operators for built in types.

  3. #3
    Registered User minime6696's Avatar
    Join Date
    Aug 2001
    Posts
    267

    Question ?

    What does that mean? Can't overloadglobal operators?

    SPH

  4. #4
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    No it's nothing to do with whether the variables or operator function is global. You can only overload operators for types you create yourself (with classes), you can't overload for int's alone otherwise the compiler doesn't know whether to use your overloaded operator or the built in one.

Popular pages Recent additions subscribe to a feed