[Help]Error: No Match For Operator

Posts 1–14 of 14 · Page 1 of 1
[Help]Error: No Match For Operator
What is the error plz? i don't understand

Error:

Visual Basic\C++\pratique\main.cpp|10|error: no match for 'operator<<' in 'std::cout << duree1'|

main.cpp:

Code:
#include <iostream>
#include "duree.h"

using namespace std;

int main()
{
    Duree duree1(0, 203, 158);

    cout<<Duree1;

    return 0;
}
Duree.h:

Code:
#ifndef DUREE_H_INCLUDED
#define DUREE_H_INCLUDED

class Duree
{
    public:
 
    Duree(int heures = 0, int minutes = 0, int secondes = 0);
 
    private:
 
    int m_heures;
    int m_minutes;
    int m_secondes;
};


#endif // DUREE_H_INCLUDED
Duree.cpp:

Code:
#include "Duree.h"
 
Duree::Duree(int heures, int minutes, int secondes)
}
    m_heures = heures;
    m_minutes = minutes;
    m_secondes = secondes;
    
    if (m_secondes >= 60)
    {
        while (m_secondes >= 60)
        {
            m_seconde -= 60;
            m_minutes += 1;
        }
        
    }
    
    if (m_minutes >= 60)
    {
        while (m_minutes)
        {
            m_minutes -= 60;
            m_heures += 1;
        }
    
    }
    
}
Thank u
Try outputing a member of the class, not the instance itself.

[php]
cout << duree1.m_heures;
[/php]

You're going to have to make them public members of the class though, or you can make a function that returns the value of private members for you.
Use get and set methods
omg i this looked like spanish to me
lol thank u.I knew that I'm just noob But Thank u!


Quote Originally Posted by scimmyboy View Post
omg i this looked like spanish to me
Yeah i,m french
Donator doesn't mean right to spam
Quote Originally Posted by NextGen1 View Post
Donator doesn't mean right to spam
It could. |:
Quote Originally Posted by NextGen1 View Post
Donator doesn't mean right to spam
whos the donator??? LEMME AT EM
Cons of Donator = Yucky Color Nam
Pro's of Donator = Spam Away
You need to make operators for your Duree class.

Code:
Duree& operator=(std::string Data)
{
// do whatever you need to.
return *this;
}
Quote Originally Posted by freedompeace View Post
You need to make operators for your Duree class.

Code:
Duree& operator=(std::string Data)
{
// do whatever you need to.
return *this;
}
Why do I need to return a pointer of this... this isn't already a pointer?
Quote Originally Posted by Gab View Post
Why do I need to return a pointer of this... this isn't already a pointer?
I couldnt see your code, just your problem (mobile theme cuts off after 3 characters of code, and I can get out of it)

You are returning a l-amber value. Also, you dont return (this) unless (this) is of type std::string, you turn an std::string. For example, you might have an int in your data, and to return it, you'd sprintf it into a LPCSTR and return that (if the operator was an LPCSTR)

(This) was just part of a large class I have (in Gingerbread for accessing the registry).

If this doesn't make sense, i apologise, please post back here for clarification.
Is that really how much money mpgh has? dang they are rich
Could u make the function? Cause i don't understand
Posts 1–14 of 14 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us