Konstruktor



  • Gut erstmal erledigt 😃

    Melde mich vielleicht bei weiteren Problemen



  • https://www.pic-upload.de/view-33091301/k.png.html

    Die get Methoden haben ich soweit implementiert.

    Kann mir jemand erklären wie man mittels ostream ausgibt?

    #include "CTitle.h"
    
    CTitle::CTitle(int contentSize, int duration, string name, string performer,
    		int bitRate)
    {
    	if(bitRate>= 32000 && bitRate <= 320000 ){
    
    		m_bitRate = bitRate;
    	}
    	else {
    		m_contentSize = 0;
    		m_duration = 0;
    		m_duration = 0;
    	}
    }
    
    string CTitle::getName() const
    {
    	return m_name;
    }
    
    string CTitle::getPerformer() const
    {
    	return m_performer;
    }
    
    int CTitle::getDuration() const
    {
    	return m_duration;
    }
    




  • Such mal nach "c++ stream operator", z.B. Input/Output operators overloading in C++.

    @axels: In der Doku steht dies leider nicht direkt drin, da dort nur die direkten Member der Klasse beschrieben sind.



  • Im Header habe ich den Operator schon mal definiert.

    * CTitle.h
     *
     *  Created on: 11.07.2015
     *      Author: mnl
     */
    
    #ifndef CTITLE_H_
    #define CTITLE_H_
    
    #include <string>
    using namespace std;
    
    /**
     * Diese Klasse beschreibt einen MP3-kodierten Titel (Song).
     */
    class CTitle
    {
    private:
    	/** Name (Titel) des Songs */
    	string m_name;
    
    	/** Ausführende(r) (Interpret, Gruppe, Orchester o. ä.) */
    	string m_performer;
    
    	/** Die Dauer des Titels in Sekunden. */
    	int m_duration;
    
    	/** Die Bitrate in bit/s. */
    	int m_bitRate;
    
    	/** Die Größe (Anzahl der Bytes) der Audiodaten. */
    	int m_contentSize;
    
    public:
    	/**
    	 * Erzeugt ein neues Objekt, dessen Attribute mit den angegebenen
    	 * Werten initialisiert werden.
    	 *
    	 * Falls Name oder Ausführende(r) (performer) leer sind, werden
    	 * die Default-Werte verwendet.
    	 *
    	 * Die Angabe der Bitrate erfolgt in bit/s.
    	 *
    	 * Die Bitrate muss zwischen 32000 und 320000 bit/s liegen.
     	 * Falls diese Zusicherung verletzt wird, werden die Attribute
    	 * m_bitRate, m_duration und m_contentSize auf 0 gesetzt.
    	 */
    	CTitle(int contentSize = 0, int duration = 0,
    		   string name = "(Untitled)", string performer = "(Unknown)",
    		   int bitRate = 128000);
    
    	/**
    	 * Diese Methode liefert den Namen des Titels.
    	 */
    	string getName() const;
    
    	/**
    	 * Diese Methode liefert den Ausführenden (Performer).
    	 */
    	string getPerformer() const;
    
    	/**
    	 * Diese Methode liefert die Dauer (Länge) des Titels in Sekunden.
    	 */
    	int getDuration() const;
    	friend ostream& operator << (ostream& lop, CTitle& rop);
    };
    
    #endif /* CTITLE_H_ */
    
    /*
     * CTitle.cpp
     *
     *  Created on: 13.07.2015
     *      Author: Michael
     */
    
    #include "CTitle.h"
    
    CTitle::CTitle(int contentSize, int duration, string name, string performer,
    		int bitRate)
    {
    	if(bitRate>= 32000 && bitRate <= 320000 ){
    
    		m_bitRate = bitRate;
    	}
    	else {
    		m_contentSize = 0;
    		m_duration = 0;
    		m_duration = 0;
    	}
    }
    
    string CTitle::getName() const
    {
    	return m_name;
    }
    
    string CTitle::getPerformer() const
    {
    	return m_performer;
    }
    
    int CTitle::getDuration() const
    {
    	return m_duration;
    }
    
    ostream& operator << (ostream& lop, CTitle& rop){
    
    }
    

    contentSize soll ja mit maximal 4 stellen in Byte dargestellt werden ?
    Mein Problem ist es jetzt das ich nicht weiss wie man das genau als 4 Byte darstellen soll?



  • welche uni hat eigtl diese aufgabe?
    gibts hier häufiger mal.

    https://www.c-plusplus.net/forum/339181-full



  • #include "CTitle.h"
    
    CTitle::CTitle(int contentSize, int duration, string name, string performer,
    		int bitRate)
    {
    	 if(m_contentSize < 0 || m_contentSize > 0){
    
    	        m_contentSize = contentSize;
    	    }
    	        else{
    
    	        m_contentSize = 0;
    	    }
    
    	 if(m_duration <= 0 || m_duration >= 0){
    
    	        m_duration = duration;
    	 }
    
    	        else{
    
    	        m_duration = 0;
    	    }
    
    	 m_name = name;
    	 m_performer = performer;
    	if(bitRate>= 32000 && bitRate <= 320000 ){
    
    		m_bitRate = bitRate;
    	}
    	else {
    		m_contentSize = 0;
    		m_duration = 0;
    		m_duration = 0;
    	}
    }
    
    string CTitle::getName() const
    {
    	return m_name;
    }
    
    string CTitle::getPerformer() const
    {
    	return m_performer;
    }
    
    int CTitle::getDuration() const
    {
    	return m_duration;
    }
    
    ostream& operator << (ostream& lop, CTitle& rop){
    	  lop<< &rop << " " << rop.getName();
    	    lop<< "; " << rop.getPerformer();
    	    lop<< " ; " << rop.getDuration();
    	    lop << " s"; //Ausgabe um s erweitert
    
    	    if (rop.m_contentSize > 9999 * 1024){ // > 9999 KiB
    	        lop << rop.m_contentSize / (1024 * 1024) << " MiB";
    	    }
    	    else if (rop.m_contentSize > 9999){ // > 9999 B{
    	        lop << rop.m_contentSize / 1024 << " KiB";
    	    }
    	    else{
    	        lop << rop.m_contentSize << " B"
    	    }
    
    	return lop;
    
    }
    

    * CTitle.h
    *
    * Created on: 11.07.2015
    * Author: mnl
    */

    #ifndef CTITLE_H_
    #define CTITLE_H_

    #include <string>
    using namespace std;

    /**
    * Diese Klasse beschreibt einen MP3-kodierten Titel (Song).
    */
    class CTitle
    {
    private:
    /** Name (Titel) des Songs */
    string m_name;

    /** Ausführende(r) (Interpret, Gruppe, Orchester o. ä.) */
    string m_performer;

    /** Die Dauer des Titels in Sekunden. */
    int m_duration;

    /** Die Bitrate in bit/s. */
    int m_bitRate;

    /** Die Größe (Anzahl der Bytes) der Audiodaten. */
    int m_contentSize;

    public:
    /**
    * Erzeugt ein neues Objekt, dessen Attribute mit den angegebenen
    * Werten initialisiert werden.
    *
    * Falls Name oder Ausführende(r) (performer) leer sind, werden
    * die Default-Werte verwendet.
    *
    * Die Angabe der Bitrate erfolgt in bit/s.
    *
    * Die Bitrate muss zwischen 32000 und 320000 bit/s liegen.
    * Falls diese Zusicherung verletzt wird, werden die Attribute
    * m_bitRate, m_duration und m_contentSize auf 0 gesetzt.
    */
    CTitle(int contentSize = 0, int duration = 0,
    string name = "(Untitled)", string performer = "(Unknown)",
    int bitRate = 128000);

    /**
    * Diese Methode liefert den Namen des Titels.
    */
    string getName() const;

    /**
    * Diese Methode liefert den Ausführenden (Performer).
    */
    string getPerformer() const;

    /**
    * Diese Methode liefert die Dauer (Länge) des Titels in Sekunden.
    */
    int getDuration() const;
    friend ostream& operator << (ostream& lop, CTitle& rop);
    };

    #endif /* CTITLE_H_ */[code="cpp"]

    Habe den code soweit kopiert .
    Aber warum werden Fehler angezeigt beim ostream operator ?

    Description Resource Path Location Type
    conversion to non-const reference type 'class CTitle&' from rvalue of type 'CTitle' [-fpermissive] CTitle.cpp /CTitle line 63 C/C++ Problem
    conversion to non-const reference type 'class CTitle&' from rvalue of type 'CTitle' [-fpermissive] CTitle.cpp /CTitle line 64 C/C++ Problem
    conversion to non-const reference type 'class CTitle&' from rvalue of type 'CTitle' [-fpermissive] CTitle.cpp /CTitle line 65 C/C++ Problem
    conversion to non-const reference type 'class CTitle&' from rvalue of type 'CTitle' [-fpermissive] CTitle.cpp /CTitle line 66 C/C++ Problem
    invalid conversion from 'const char*' to 'int' [-fpermissive] CTitle.cpp /CTitle line 64 C/C++ Problem
    invalid conversion from 'const char*' to 'int' [-fpermissive] CTitle.cpp /CTitle line 65 C/C++ Problem
    invalid conversion from 'const char*' to 'int' [-fpermissive] CTitle.cpp /CTitle line 66 C/C++ Problem
    invalid conversion from 'CTitle*' to 'int' [-fpermissive] CTitle.cpp /CTitle line 63 C/C++ Problem
    invalid initialization of non-const reference of type 'CTitle&' from an rvalue of type 'CTitle' CTitle.cpp /CTitle line 69 C/C++ Problem
    invalid initialization of non-const reference of type 'CTitle&' from an rvalue of type 'CTitle' CTitle.cpp /CTitle line 72 C/C++ Problem
    invalid initialization of non-const reference of type 'CTitle&' from an rvalue of type 'CTitle' CTitle.cpp /CTitle line 75 C/C++ Problem
    invalid user-defined conversion from 'const char [3]' to 'CTitle&' [-fpermissive] CTitle.cpp /CTitle line 64 C/C++ Problem
    invalid user-defined conversion from 'const char [3]' to 'CTitle&' [-fpermissive] CTitle.cpp /CTitle line 66 C/C++ Problem
    invalid user-defined conversion from 'const char [4]' to 'CTitle&' [-fpermissive] CTitle.cpp /CTitle line 65 C/C++ Problem
    invalid user-defined conversion from 'CTitle*' to 'CTitle&' [-fpermissive] CTitle.cpp /CTitle line 63 C/C++ Problem
    no match for 'operator<<' (operand types are 'std::ostream {aka std::basic_ostream<char>}' and 'const char [3]') CTitle.cpp /CTitle line 64 C/C++ Problem
    no match for 'operator<<' (operand types are 'std::ostream {aka std::basic_ostream<char>}' and 'const char [3]') CTitle.cpp /CTitle line 66 C/C++ Problem
    no match for 'operator<<' (operand types are 'std::ostream {aka std::basic_ostream<char>}' and 'const char [4]') CTitle.cpp /CTitle line 65 C/C++ Problem
    no match for 'operator<<' (operand types are 'std::ostream {aka std::basic_ostream<char>}' and 'CTitle*') CTitle.cpp /CTitle line 63 C/C++ Problem
    no match for 'operator<<' (operand types are 'std::ostream {aka std::basic_ostream<char>}' and 'int') CTitle.cpp /CTitle line 69 C/C++ Problem
    no match for 'operator<<' (operand types are 'std::ostream {aka std::basic_ostream<char>}' and 'int') CTitle.cpp /CTitle line 72 C/C++ Problem
    no match for 'operator<<' (operand types are 'std::ostream {aka std::basic_ostream<char>}' and 'int') CTitle.cpp /CTitle line 75 C/C++ Problem
    after user-defined conversion: CTitle::CTitle(int, int, std::__cxx11::string, std::__cxx11::string, int) CTitle.cpp /CTitle line 10 C/C++ Problem
    conversion of argument 1 would be ill-formed: CTitle.cpp /CTitle line 10 C/C++ Problem
    conversion of argument 2 would be ill-formed: CTitle.cpp /CTitle line 62 C/C++ Problem
    initializing argument 1 of 'CTitle::CTitle(int, int, std::__cxx11::string, std::__cxx11::string, int)' CTitle.cpp /CTitle line 10 C/C++ Problem
    mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'const char [3]' CTitle.cpp /CTitle line 64 C/C++ Problem
    mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'const char [3]' CTitle.cpp /CTitle line 66 C/C++ Problem
    mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'const char [4]' CTitle.cpp /CTitle line 65 C/C++ Problem
    mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'CTitle*' CTitle.cpp /CTitle line 63 C/C++ Problem
    mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int' CTitle.cpp /CTitle line 69 C/C++ Problem
    mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int' CTitle.cpp /CTitle line 72 C/C++ Problem
    mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int' CTitle.cpp /CTitle line 75 C/C++ Problem
    template argument deduction/substitution failed: CTitle line 5325, external location: C:\PROGRA~1\GIT\eclipse\mingw\mingw64\include\c++\6.3.0\bits\basic_string.h C/C++ Problem
    candidate is: CTitle::CTitle(int, int, std::__cxx11::string, std::__cxx11::string, int) <near match> CTitle.cpp /CTitle line 10 C/C++ Problem
    candidate: std::ostream& operator<<(std::ostream&, CTitle&) <near match> CTitle.cpp /CTitle line 62 C/C++ Problem
    candidate: template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) CTitle line 5325, external location: C:\PROGRA~1\GIT\eclipse\mingw\mingw64\include\c++\6.3.0\bits\basic_string.h C/C++ Problem

    Kann mir jemand vielleicht die if Bedingungen beim ostream erklären ?
    Selbst bin ich ja nicht darauf gekommen.
    Ich übe ja und daher hilft es mir nicht nur den Code zu kopieren 😃

    Wäre sehr nett wenn jemand Zeit hat und mir das erklären kann?



  • Bei dem ostream& << operator musst du dein Objekt CTitle als const-reference übergeben.

    Sonst änderst du in den Zeilen

    lop << rop.m_contentSize / (1024 * 1024) << " MiB";
    

    und

    lop << rop.m_contentSize / 1024 << " KiB";
    

    den Zustand deines Objektes.

    Denn wenn du dein rop als reference übergibst, greifst du ja in der Funktion direkt auf das Objekt zu und nicht auf eine Kopie oder eine nicht-änderbare Referenz. Sprich würdest du die Membervariablen verändern, und das darf bei einer Ausgabe nicht passieren.

    Am besten noch eine Funktion definieren die in etwa so aus sieht

    int CTitle::contentSize()const
    {
    return m_contentSize();
    }
    

    Somit würde der Operator so aussehen.
    Vergiss nicht im Header bei der Definition das const hinzuzufügen.

    ostream& operator << (ostream& lop, const CTitle& rop){
          lop<< &rop << " " << rop.getName();
            lop<< "; " << rop.getPerformer();
            lop<< " ; " << rop.getDuration();
            lop << " s"; //Ausgabe um s erweitert
    
            if (rop.m_contentSize > 9999 * 1024){ // > 9999 KiB
                lop << rop.contentSize() / (1024 * 1024) << " MiB";
            }
            else if (rop.m_contentSize > 9999){ // > 9999 B{
                lop << rop.contentSize() / 1024 << " KiB";
            }
            else{
                lop << rop.contentSize() << " B"
            }
    
        return lop;
    
    }
    

    Sehr guter Beitrag im Forum zum Thema Überladung von Operatoren
    https://www.c-plusplus.net/forum/232010-full



  • #ifndef CTITLE_H_
    #define CTITLE_H_
    
    #include <string>
    using namespace std;
    
    /**
     * Diese Klasse beschreibt einen MP3-kodierten Titel (Song).
     */
    class CTitle
    {
    private:
    	/** Name (Titel) des Songs */
    	string m_name;
    
    	/** Ausführende(r) (Interpret, Gruppe, Orchester o. ä.) */
    	string m_performer;
    
    	/** Die Dauer des Titels in Sekunden. */
    	int m_duration;
    
    	/** Die Bitrate in bit/s. */
    	int m_bitRate;
    
    	/** Die Größe (Anzahl der Bytes) der Audiodaten. */
    	int m_contentSize;
    
    public:
    	/**
    	 * Erzeugt ein neues Objekt, dessen Attribute mit den angegebenen
    	 * Werten initialisiert werden.
    	 *
    	 * Falls Name oder Ausführende(r) (performer) leer sind, werden
    	 * die Default-Werte verwendet.
    	 *
    	 * Die Angabe der Bitrate erfolgt in bit/s.
    	 *
    	 * Die Bitrate muss zwischen 32000 und 320000 bit/s liegen.
     	 * Falls diese Zusicherung verletzt wird, werden die Attribute
    	 * m_bitRate, m_duration und m_contentSize auf 0 gesetzt.
    	 */
    	CTitle(int contentSize = 0, int duration = 0,
    		   string name = "(Untitled)", string performer = "(Unknown)",
    		   int bitRate = 128000);
    
    	/**
    	 * Diese Methode liefert den Namen des Titels.
    	 */
    	string getName() const;
    
    	int contentSize() const;
    
    	/**
    	 * Diese Methode liefert den Ausführenden (Performer).
    	 */
    	string getPerformer() const;
    
    	/**
    	 * Diese Methode liefert die Dauer (Länge) des Titels in Sekunden.
    	 */
    	int getDuration() const;
    	friend ostream& operator << (ostream& lop, CTitle& rop);
    };
    
    #endif /* CTITLE_H_ */
    

    cpp

    
    

    #include "CTitle.h"

    CTitle::CTitle(int const contentSize, int duration, string name, string performer,
    int bitRate)
    {
    if(m_contentSize < 0 || m_contentSize > 0){

    m_contentSize = contentSize;
    }
    else{

    m_contentSize = 0;
    }

    if(m_duration <= 0 || m_duration >= 0){

    m_duration = duration;
    }

    else{

    m_duration = 0;
    }

    m_name = name;
    m_performer = performer;
    if(bitRate>= 32000 && bitRate <= 320000 ){

    m_bitRate = bitRate;
    }
    else {
    m_contentSize = 0;
    m_duration = 0;
    m_duration = 0;
    }
    }

    string CTitle::getName() const
    {
    return m_name;
    }

    string CTitle::getPerformer() const
    {
    return m_performer;
    }

    int CTitle::getDuration() const
    {
    return m_duration;
    }
    int CTitle::contentSize()const
    {
    return m_contentSize;
    }

    ostream& operator << (ostream& lop, const CTitle& rop){
    lop<< &rop << " " << rop.getName();
    lop<< "; " << rop.getPerformer();
    lop<< " ; " << rop.getDuration();
    lop << " s"; //Ausgabe um s erweitert

    if (rop.m_contentSize > 9999 * 1024){ // > 9999 KiB
    lop << rop.contentSize() / (1024 * 1024) << " MiB";
    }
    else if (rop.m_contentSize > 9999){ // > 9999 B{
    lop << rop.contentSize() / 1024 << " KiB";
    }
    else{
    lop << rop.contentSize() << " B"
    }

    return lop;

    }

    [code="cpp"]

    Immer noch bei knapp 25 Fehler 😃

    Description Resource Path Location Type
    'int CTitle::m_contentSize' is private within this context CTitle.cpp /CTitle line 72 C/C++ Problem
    'int CTitle::m_contentSize' is private within this context CTitle.cpp /CTitle line 75 C/C++ Problem
    conversion to non-const reference type 'class CTitle&' from rvalue of type 'CTitle' [-fpermissive] CTitle.cpp /CTitle line 67 C/C++ Problem
    invalid conversion from 'const char*' to 'int' [-fpermissive] CTitle.cpp /CTitle line 68 C/C++ Problem
    invalid conversion from 'const char*' to 'int' [-fpermissive] CTitle.cpp /CTitle line 69 C/C++ Problem
    invalid conversion from 'const char*' to 'int' [-fpermissive] CTitle.cpp /CTitle line 70 C/C++ Problem
    invalid conversion from 'const char*' to 'int' [-fpermissive] CTitle.cpp /CTitle line 73 C/C++ Problem
    invalid conversion from 'const char*' to 'int' [-fpermissive] CTitle.cpp /CTitle line 76 C/C++ Problem
    invalid conversion from 'const char*' to 'int' [-fpermissive] CTitle.cpp /CTitle line 79 C/C++ Problem
    invalid conversion from 'const CTitle*' to 'int' [-fpermissive] CTitle.cpp /CTitle line 67 C/C++ Problem
    invalid user-defined conversion from 'const char [3]' to 'const CTitle&' [-fpermissive] CTitle.cpp /CTitle line 68 C/C++ Problem
    invalid user-defined conversion from 'const char [3]' to 'const CTitle&' [-fpermissive] CTitle.cpp /CTitle line 70 C/C++ Problem
    invalid user-defined conversion from 'const char [3]' to 'const CTitle&' [-fpermissive] CTitle.cpp /CTitle line 79 C/C++ Problem
    invalid user-defined conversion from 'const char [4]' to 'const CTitle&' [-fpermissive] CTitle.cpp /CTitle line 69 C/C++ Problem
    invalid user-defined conversion from 'const char [5]' to 'const CTitle&' [-fpermissive] CTitle.cpp /CTitle line 73 C/C++ Problem
    invalid user-defined conversion from 'const char [5]' to 'const CTitle&' [-fpermissive] CTitle.cpp /CTitle line 76 C/C++ Problem
    invalid user-defined conversion from 'const CTitle*' to 'const CTitle&' [-fpermissive] CTitle.cpp /CTitle line 67 C/C++ Problem
    invalid user-defined conversion from 'const CTitle*' to 'CTitle&' [-fpermissive] CTitle.cpp /CTitle line 67 C/C++ Problem
    no match for 'operator<<' (operand types are 'std::ostream {aka std::basic_ostream<char>}' and 'const char [3]') CTitle.cpp /CTitle line 68 C/C++ Problem
    no match for 'operator<<' (operand types are 'std::ostream {aka std::basic_ostream<char>}' and 'const char [3]') CTitle.cpp /CTitle line 70 C/C++ Problem
    no match for 'operator<<' (operand types are 'std::ostream {aka std::basic_ostream<char>}' and 'const char [3]') CTitle.cpp /CTitle line 79 C/C++ Problem
    no match for 'operator<<' (operand types are 'std::ostream {aka std::basic_ostream<char>}' and 'const char [4]') CTitle.cpp /CTitle line 69 C/C++ Problem
    no match for 'operator<<' (operand types are 'std::ostream {aka std::basic_ostream<char>}' and 'const char [5]') CTitle.cpp /CTitle line 73 C/C++ Problem
    no match for 'operator<<' (operand types are 'std::ostream {aka std::basic_ostream<char>}' and 'const char [5]') CTitle.cpp /CTitle line 76 C/C++ Problem
    no match for 'operator<<' (operand types are 'std::ostream {aka std::basic_ostream<char>}' and 'const CTitle*') CTitle.cpp /CTitle line 67 C/C++ Problem
    conversion of argument 1 would be ill-formed: CTitle.cpp /CTitle line 10 C/C++ Problem
    conversion of argument 2 would be ill-formed: CTitle.cpp /CTitle line 66 C/C++ Problem
    conversion of argument 2 would be ill-formed: CTitle.h /CTitle line 69 C/C++ Problem
    initializing argument 1 of 'CTitle::CTitle(int, int, std::__cxx11::string, std::__cxx11::string, int)' CTitle.cpp /CTitle line 10 C/C++ Problem
    mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'const char [3]' CTitle.cpp /CTitle line 68 C/C++ Problem
    mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'const char [3]' CTitle.cpp /CTitle line 70 C/C++ Problem
    mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'const char [3]' CTitle.cpp /CTitle line 79 C/C++ Problem
    mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'const char [4]' CTitle.cpp /CTitle line 69 C/C++ Problem
    mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'const char [5]' CTitle.cpp /CTitle line 73 C/C++ Problem
    mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'const char [5]' CTitle.cpp /CTitle line 76 C/C++ Problem
    mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'const CTitle*' CTitle.cpp /CTitle line 67 C/C++ Problem
    template argument deduction/substitution failed: CTitle line 5325, external location: C:\PROGRA~1\GIT\eclipse\mingw\mingw64\include\c++\6.3.0\bits\basic_string.h C/C++ Problem
    candidate is: CTitle::CTitle(int, int, std::__cxx11::string, std::__cxx11::string, int) <near match> CTitle.cpp /CTitle line 10 C/C++ Problem
    candidate: std::ostream& operator<<(std::ostream&, const CTitle&) <near match> CTitle.cpp /CTitle line 66 C/C++ Problem
    candidate: std::ostream& operator<<(std::ostream&, CTitle&) <near match> CTitle.h /CTitle line 69 C/C++ Problem
    candidate: template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) CTitle line 5325, external location: C:\PROGRA~1\GIT\eclipse\mingw\mingw64\include\c++\6.3.0\bits\basic_string.h C/C++ Problem
    declared private here CTitle.h /CTitle line 33 C/C++ Problem



  • Es gibt schon einen Grund für den Vorschauknopf. Benutze ihn, dann siehst du, wenn die Codetags fehlerhaft sind.



  • if(m_duration <= 0 || m_duration >= 0){ 
    
    m_duration = duration; 
    } 
    
    else{ 
    
    m_duration = 0; 
    }
    

    kannst du mal erklären, was das machen soll?
    + kannst du mal erklären, wieso eine negative duration mgl sein soll?



  • Das war in dem Code von dem link drinnen ?
    Das war nicht meine Idee .
    Ich hatte ja auch die Leute gebeten mir ein wenig den Vode zu erklären , da ich es nicht verstehe .
    Leider kam nix 😃



  • axels hat in seinem Beitrag alles erklaert was es zu den Aenderungen zu erklaeren gibt. Er hat sogar noch einen Beitrag zum ueberladen von operatoren verlinkt. Wenn du es nicht verstehst, dann stell praezise Fragen.



  • @ axel bin ich dankbar.
    Er hat es sehr schön erklärt.
    Ich hatte nicht so ganz die logik hinter der If Bedingungen verstanden ?

    Warum wurde das gemacht ?

    if (rop.m_contentSize > 9999 * 1024){ // > 9999 KiB
    lop << rop.contentSize() / (1024 * 1024) << " MiB";
    }
    else if (rop.m_contentSize > 9999){ // > 9999 B{
    lop << rop.contentSize() / 1024 << " KiB";
    }
    else{
    lop << rop.contentSize() << " B"
    }

    Warum hier mal genommen? 9999 * 1024.

    Und die weitere Rechnung auch nicht verstanden .


Anmelden zum Antworten