Member functions inside struct

hi all , I am using the minGW C++ compiler with the DEV C++ ide on the windows vista ,

I just write this struct , but this is failling , I spend several hours digging and researching on the internet , But I unable to find it.


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
/* this is the lines structure then */
struct  lines 
{
       vector<line>* lines_vector   ;
       int a ;
       // the constructor will create get a char* and torkernize it into the 
       //   lines and make line objects and push them into the vector.
 
       char * getline (int line ) 
       {
            // this will output line number 'line'
            line requested_line = lines_vector.at(line);  // the error is here 
            return requested_line.str1 ;
       }
       
       int get_num_lines () 
       {
           return (int )lines_vector.size();
       }
 
       lines ( char * str , int length ) 
       {
             lines_vector = new vector<line>;
             int current_position = 0 ;
             int current_line_position = 0 ;
             while ( current_position <=  length )
             {
                   char current_line [200] ; // we are assuming that the current line is not
                                             // greater than the 200 characters... however this is NUTS
                   
                   // the we are just copy them to our buffer
                   current_line [  current_line_position ] = str [current_position] ;
                                
                   // if we found a '\n' then we should create and push the current line 
                   // and also reset the current_line_position to zero                            
                   if ( str [ current_position ] == '\n')
                   {
                           // then create a new object of line
                           line * new_line = new line ( current_line ,   current_position );
                           lines_vector->push_back ( *new_line ) ;             
                        
                   }
                   current_line_position++ ;
                   current_position++ ;
                         
             }
       
       }
       

};


The error is
"expected ';' before 'requested_line"

Anyway I really wondering what is the syntax error That I have did.
If line is a valid type, just rename your argument
1
2
3
4
5
6
char * getline (int Line ) 
       {
            line requested_line = lines_vector.at(Line);
            return requested_line.str1 ;
       }
well , I don't know why I don't seen that .
anyway need's more patient when digging into the code .


ya I have learned that !
Topic archived. No new replies allowed.