| | |
String declaration in class definition
![]() |
I'm trying to create class/header for my program which should calculate distanaces between cities declared by array "use" plus arrays of there coordinates as you see in code below
I created prototypes of functions in cc program and tryed to compile, but got this error messages
My main concern is the declaration of string use and dest. Can you please explain me what I did wrong?
C Syntax (Toggle Plain Text)
// file line.h #ifndef LINE_H #define LINE_H const int cities = 6; class Line { private: string use[] = {"Phoenix", "Baton Rouge", "Bismark", "Columbia", "Olympia", "Springfield"}; //predefined parameters name of cities int x[] = {380, 890, 650, 1140, 70, 920}; // x coordinate of each city int y[] = {280, 180, 690, 300, 700, 470}; // y coordinate of each city string dest[] = {"Phoenix"}; //cities which been used in calculation, as a target city and starting city int dist[]; //calculated distanced between cities int possition[] = {0, 1, 2, 3, 4, 5}; //to be use for swap function, after swaping to find city with shortest distatce from start city int calc[]; //array to hold temporary distances int x1; int x2; int y1; int y2; public: Line(); void calculate(); void find(); bool notInDest(); void sort(); void swap(); void smallest(); void display(); }; #endif;
C Syntax (Toggle Plain Text)
line.h:10: syntax error before `[' line.h:10: missing ';' before right brace line.h:14: syntax error before `[' line.h:24: parse error before `public' line.h:33: parse error before `}' line.cc:6: definition of implicitly-declared `Line::Line()' line.cc:6: declaration of `Line::Line()' outside of class is not definition line.cc:9: no `void Line::find()' member function declared in class `Line' line.cc:12: parse error before `bool' line.cc:16: parse error before `void' line.cc:20: parse error before `void' line.cc:24: parse error before `void' line.h:15: storage size of `dist' isn't known line.h:18: storage size of `calc' isn't known
![]() |
Similar Threads
- help with c++ classes (C++)
- separating headers from implementation (C++)
- HELP writing structure and class definition - Visual C++ (C++)
- needed big time hw due and late (C)
Other Threads in the C Forum
- Previous Thread: [basics] LZ(W) compression explanation.
- Next Thread: Analyzing the Round Robin Scheduling
| Thread Tools | Search this Thread |
#include * adobe ansi api array asterisks binarysearch centimeter changingto char character cm copyimagefile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax database directory dynamic feet fgets file fork frequency function getlasterror getlogicaldrivestrin givemetehcodez global grade graphics gtkgcurlcompiling gtkwinlinux hacking highest histogram include incrementoperators infiniteloop input interest kernel keyboard kilometer linked linkedlist linux linuxsegmentationfault list locate logical_drives looping loopinsideloop. lowest match matrix meter microsoft mqqueue mysql number odf opendocumentformat owf pattern pdf performance pointer posix probleminc process program programming radix recursion recv repetition research reversing scanf segmentationfault sequential shape single socket socketprograming standard string systemcall threads turboc unix user voidmain() wab whythiscodecausesegmentationfault windows.h windowsapi






