Hallo,
ich habe habe hier eine Klasse welche soweit funktioniert.. jedoch hat sie einen Makel, die private-Sektion befindet sich über der public-Sektion.. soviel ich weiß entspricht dass nicht der C++-Konvention, oder? Daher meine Frage, wie funktioniert meine Klasse auch, wenn ich die beiden Sektionenen vertausche.. ich denke mal, es liegt daran dass etwas nicht deklariert wurde.. der Compiler gibt mir unglaublich viel Fehlermeldungen aus...
Hier meine Klasse:
|
C Quellcode
|
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
|
//Includeguard ASCIIPICTURE//
#if !defined(ASCIIPICTURE_H)
#define ASCIIPICTURE_H
#include <vector>
#include <string>
#include <istream>
#include <ostream>
///////////////////////////
class AsciiPicture
{
private:
typedef std::vector<std::string> linesvector;
linesvector lines;
public:
AsciiPicture(); //DefaultKonstruktor
//Typedefs für Linesvector///////////////////////////////////
typedef linesvector::size_type size_type; //wie unsigned int
typedef linesvector::iterator iter;
typedef linesvector::const_iterator const_iter;
////////////////////////////////////////////////////////////
//Inlinefunktionen//////////////////////////////////////////
//Zeile hinzufügen
void add_line(const std::string& text);
//Zeile an bestimmter Postion hinzufügen
void add_line(const std::string& text, size_type pos);
//Zeile an bestimmter Position löschen
void delete_line (size_type pos);
//Bestimmte Zeile zurückgeben
std::string& get_line(size_type pos){
return lines.at(pos);
}
//Bestimmen der maximalen Spaltenbreite
size_type get_column ()const{
std::string::size_type max=0;
linesvector::const_iterator beginline=lines.begin();
linesvector::const_iterator endline=lines.end();
while(beginline!=endline) {
if (max < (*beginline).size()){
max=(*beginline).size();
}
++beginline;
}
return max;
}
//Ermitteln der Anzahl der Zeilen
size_type get_row()const{return lines.size();}
////////////////////////////////////////////////////////////////////
//Iteratoren und Const-Iteratoren für Anfang und Ende im LinesVector lines//
iter begin(){return lines.begin();}
iter end(){return lines.end();}
const_iter begin() const{return lines.begin();}
const_iter end() const{return lines.end();}
///////////////////////////////////////////////////////////////////////////
};
#endif
|