| | |
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 |
* adobe ansi api array asterisks binarysearch calculate centimeter char character cm convert copyanyfile copyimagefile copypdffile cprogramme createcopyoffile createprocess() csyntax directory feet fflush fgets file floatingpointvalidation fork frequency function givemetehcodez global graphics gtkgcurlcompiling gtkwinlinux hacking highest homework i/o inches infiniteloop interest intmain() iso keyboard kilometer km linked linkedlist linux linuxsegmentationfault list locate lowest match meter microsoft mqqueue mysql number oddnumber odf open opendocumentformat openwebfoundation owf pattern pdf performance posix power probleminc program programming pyramidusingturboccodes read recv recvblocked repetition reversing scanf scheduling segmentationfault send single socketprograming socketprogramming stack standard string suggestions systemcall unix urboc user variable voidmain() wab whythiscodecausesegmentationfault win32api windows.h






