Objekt Programmierung |
Windows unregistriert
|
|
Habe mal die Ostream ausgabe pobiert .
Aber was ist genau dieses s nache dem duration.
Hier meine Ansätze wenigstens .
Stecke jetzt aber irgendwie fest jetzt auch
cpp
code: |
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
|
#include "CTitle.h"
#include <string>
using namespace std;
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( m_bitRate>=32000 && m_bitRate<= 320000){
m_bitRate = bitRate;
}
else{
m_bitRate = 0;
m_duration = 0;
m_contentSize = 0;
}
}
CTitle::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();
}
|
|
header:
code: |
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
|
#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;
};
ostream& operator<< (ostream& lop, CTitle& rop);
#endif /* CTITLE_H_ */
|
|
|
|
07.08.2016 09:21 |
|
|
Karlito
Kaiser
Dabei seit: 11.04.2011
Beiträge: 1.461
|
|
Hallo,
Was für ein s meinst Du?
Ich habe mal die Fehler korrigiert und kommentiert:
code: |
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
|
#include "CTitle.h"
#include <string>
using namespace std;
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( m_bitRate>=32000 && m_bitRate<= 320000){
m_bitRate = bitRate;
}
else{
m_bitRate = 0;
m_duration = 0;
m_contentSize = 0;
}
}
string CTitle::getName() const //Hier Fehlerchen
{
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();
return lop; //return-Statement fehlte
} |
|
code: |
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
|
#ifndef CTITLE_H_
#define CTITLE_H_
#include <string>
#include <iostream> //Dieses Include fehlte!
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;
};
ostream& operator<< (ostream& lop, CTitle& rop);
#endif /* CTITLE_H_ */ |
|
|
|
07.08.2016 10:38 |
|
|
Windows unregistriert
|
|
Das s nach der duration in der Ausgabe?
|
|
07.08.2016 13:31 |
|
|
Karlito
Kaiser
Dabei seit: 11.04.2011
Beiträge: 1.461
|
|
ich kann die Ausgabe nicht nachvollziehen.
Gruß,
Karlito
|
|
07.08.2016 15:19 |
|
|
Windows unregistriert
|
|
|
07.08.2016 22:16 |
|
|
Karlito
Kaiser
Dabei seit: 11.04.2011
Beiträge: 1.461
|
|
Mein Test-Programm gibt kein "s" aus.
code: |
1:
2:
3:
4:
5:
6:
7:
8:
|
int main(int argc, char **argv){
CTitle title = CTitle();
cout << title << endl;
return 0;
}
|
|
ergibt
code: |
1:
2:
3:
|
0x7fff42086600 (Untitled); (Unknown) ; 0
|
|
Gruß,
Karlito
|
|
07.08.2016 22:58 |
|
|
Windows unregistriert
|
|
Die einzige Hilfe die jetzt noch kommen kann ist von Eulersche Zahl
Mehr Personal gibt es ja nicht
|
|
08.08.2016 08:35 |
|
|
|
Meinst du das s in der Angabe zu Aufgabe d?
Das steht für die Einheit Sekunden.
code: |
1:
2:
3:
4:
5:
6:
7:
|
ostream& operator<< (ostream& lop, CTitle& rop){
lop<< &rop << " " << rop.getName();
lop<< "; " << rop.getPerformer();
lop<< " ; " << rop.getDuration();
lop << " s"; //Ausgabe um s erweitert
} |
|
__________________ Syntax Highlighting fürs Board (Link)
|
|
08.08.2016 15:17 |
|
|
Windows unregistriert
|
|
code: |
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
|
#include "CTitle.h"
#include <string>
using namespace std;
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( m_bitRate>=32000 && m_bitRate<= 320000){
m_bitRate = bitRate;
}
else{
m_bitRate = 0;
m_duration = 0;
m_contentSize = 0;
}
}
CTitle::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
}
|
|
Warum werden aber so viele Fehler angezeigt?
Und wie kann ich auf das contentSize bei der Ausgabe zugreifen?
Description Resource Path Location Type
'string' in 'class CTitle' does not name a type CTitle.cpp /CTitle line 50 C/C++ Problem
Member declaration not found CTitle.cpp /CTitle line 50 Semantic Error
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 [4]') CTitle.cpp /CTitle line 69 C/C++ Problem
no match for 'operator<<' (operand types are 'std::ostream {aka std::basic_ostream<char>}' and 'CTitle*') CTitle.cpp /CTitle line 67 C/C++ Problem
Type 'CTitle::string' could not be resolved CTitle.cpp /CTitle line 50 Semantic Error
control reaches end of non-void function [-Wreturn-type] CEvent.cpp /CEvent line 80 C/C++ Problem
Member 'm_bookedSeats' was not initialized in this constructor CEvent.cpp /CEvent line 12 Code Analysis Problem
Member 'm_curEvents' was not initialized in this constructor CEventDB.cpp /CEvent line 14 Code Analysis Problem
no return statement in function returning non-void [-Wreturn-type] CTitle.cpp /CTitle line 72 C/C++ Problem
No return, in function returning non-void CEvent.cpp /CEvent line 53 Code Analysis Problem
No return, in function returning non-void CTitle.cpp /CTitle line 65 Code Analysis Problem
Statement has no effect 'numSeats*m_pricePerTicket' CEvent.cpp /CEvent line 98 Code Analysis Problem
statement has no effect [-Wunused-value] CEvent.cpp /CEvent line 98 C/C++ Problem
suggest parentheses around assignment used as truth value [-Wparentheses] CEvent.cpp /CEvent line 55 C/C++ Problem
suggest parentheses around assignment used as truth value [-Wparentheses] CEvent.cpp /CEvent line 60 C/C++ Problem
suggest parentheses around assignment used as truth value [-Wparentheses] CEvent.cpp /CEvent line 65 C/C++ Problem
suggest parentheses around assignment used as truth value [-Wparentheses] CEvent.cpp /CEvent line 70 C/C++ Problem
suggest parentheses around assignment used as truth value [-Wparentheses] CEvent.cpp /CEvent line 75 C/C++ Problem
mismatched types 'const std::basic_string<_CharT, _Traits, _Alloc>' and 'const char [3]' CTitle.cpp /CTitle line 68 C/C++ Problem
mismatched types 'const std::basic_string<_CharT, _Traits, _Alloc>' and 'const char [3]' CTitle.cpp /CTitle line 70 C/C++ Problem
mismatched types 'const std::basic_string<_CharT, _Traits, _Alloc>' and 'const char [4]' CTitle.cpp /CTitle line 69 C/C++ Problem
mismatched types 'const std::basic_string<_CharT, _Traits, _Alloc>' and 'CTitle*' CTitle.cpp /CTitle line 67 C/C++ Problem
no known conversion for argument 2 from 'const char [3]' to 'CTitle&' CTitle.cpp /CTitle line 65 C/C++ Problem
no known conversion for argument 2 from 'const char [4]' to 'CTitle&' CTitle.cpp /CTitle line 65 C/C++ Problem
no known conversion for argument 2 from 'CTitle*' to 'CTitle&' CTitle.cpp /CTitle line 65 C/C++ Problem
template argument deduction/substitution failed: CTitle line 2753, external location: c:\program files\git\eclipse\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\basic_string
.h C/C++ Problem
candidates are: CTitle.cpp /CTitle line 67 C/C++ Problem
candidates are: CTitle.cpp /CTitle line 68 C/C++ Problem
candidates are: CTitle.cpp /CTitle line 69 C/C++ Problem
candidates are: CTitle.cpp /CTitle line 70 C/C++ Problem
std::ostream& operator<<(std::ostream&, CTitle&) CTitle.cpp /CTitle line 65 C/C++ Problem
template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) CTitle line 2753, external location: c:\program files\git\eclipse\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\basic_string
.h C/C++ Problem
|
|
08.08.2016 21:35 |
|
|
Windows unregistriert
|
|
Fehler beseitigt
code: |
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
|
#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;
};
ostream& operator<< (ostream& lop, CTitle& rop);
#endif /* CTITLE_H_ */
|
|
code: |
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
|
#include "CTitle.h"
#include <string>
#include<iostream>
using namespace std;
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( m_bitRate>=32000 && m_bitRate<= 320000){
m_bitRate = bitRate;
}
else{
m_bitRate = 0;
m_duration = 0;
m_contentSize = 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
}
|
|
Was ich jetzt nicht genau an der Aufgabe verstehe wie ich dieses contentSize ausgeben soll?
Wie soll ich dieses präfix verwenden ?
|
|
09.08.2016 21:29 |
|
|
Windows unregistriert
|
|
Keine Tipps mehr Eulersche Zahl ?
|
|
12.08.2016 15:17 |
|
|
Windows unregistriert
|
|
Ist jemand da der noch helfen kann ?
|
|
14.08.2016 00:11 |
|
|
Windows unregistriert
|
|
Alle angaben stehen im Header .
Die cpp habe ich selber implementiert.
Ist der Konstruktor falsch wie ich den Implementiert hab?
Wir haben nur header bekommen und aufgabenstellung .
|
|
14.08.2016 10:25 |
|
|
|