| | |
The error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ <class name>
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Nov 2007
Posts: 28
Reputation:
Solved Threads: 0
Hi everyone, I'm new to C and have been given a C program to complete but found it includes many versions of the titled error for each class file.
Can anyone please explain why it occurs and how I could get rid of them?
Thanks,
Cleo
Example of a class:
Can anyone please explain why it occurs and how I could get rid of them?
Thanks,
Cleo
C Syntax (Toggle Plain Text)
q2.c:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘spellChecker’
Example of a class:
C Syntax (Toggle Plain Text)
class spellChecker { protected: struct wordRecord* wordList; public: spellChecker() { wordList=NULL; } };
•
•
Join Date: Nov 2007
Posts: 28
Reputation:
Solved Threads: 0
•
•
•
•
its actually not a C program.Your program is in C++.Anyways
Which compiler you are using?
post a stand alone code so that we cant check the error!!
If you don't mind, I have a new question with a new error.
I have a few of these:
error: ‘wordPointer’ was not declared in this scope
error: ‘malloc’ was not declared in this scope
so I passed wordPointer as a parameter (char* wordPointer)
but then found this brought me further errors for each variable I've defined within a structure or the class.
How do I allow these variables to be used publicly?
bool caseInsensitivelyEqual(char* s1, char* s2) {
int i=0;
bool same=true;
while (s1[i] && s2[i] && same) {
same=(tolower(s1[i])==tolower(s2[i]));
i++;
}
if (s1[i] || s2[i]) same=false;
return same;
}
Here are the variables I am using in my print method.
struct wordRecord {
char* word;
struct wordRecord* next;
};
class spellChecker {
protected:
struct wordRecord* wordList;
public:
spellChecker() {
wordList=NULL;
}
};and the other 2 variables I am using for my print method are within
my case sensitive spellChecker class
struct wordRecord *root; struct wordRecord *wordPointer; root = malloc(sizeof( struct wordRecord)); root -> next = 0; root -> word = dest; wordPointer = root;
print method: I have passed them as parameters below:
C Syntax (Toggle Plain Text)
void printDict(char* wordPointer, char* root, char* word, char* next) { //Step through dictionary, printing each word wordPointer -> root; while(wordPointer != NULL) { printf("%s\n", wordPointer -> word); wordPointer = wordPointer -> next; } }
And the further errors I received:
error: request for member ‘root’ in ‘* wordPointer’, which is of non-class type ‘char’
error: request for member ‘word’ in ‘* wordPointer’, which is of non-class type ‘char’
error: request for member ‘next’ in ‘* wordPointer’, which is of non-class type ‘char’
![]() |
Similar Threads
- Compilation Error (C)
- Custom pascal triangle ? (C)
- error: expected class-name before '{' token (C++)
- Need help linking java to c with multiple OS support. (Java)
- compiling linux driver in eclipse (C)
- libgpod3 + gtkpod (*nix Software)
- uint64_t + gcc + openDBX compilation error (C)
- linked list error (C)
Other Threads in the C Forum
- Previous Thread: Problem!!! Pls. help!!!
- Next Thread: Modifying the strstr function
Views: 965 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for C
adobe ansi api array arrays bash binarysearch centimeter char convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory drawing dynamic executable fflush file fork frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hardware highest homework i/o inches infiniteloop initialization interest kilometer km lazy linked linkedlist linux linuxsegmentationfault list locate logical_drives match matrix meter microsoft motherboard multi mysql open opendocumentformat opensource owf pattern pdf performance pointer pointers posix power problem probleminc program programming pyramidusingturboccodes read recursion recv repetition scanf scheduling segmentationfault send shape socketprograming spoonfeeding stack standard strchr string strings structures student suggestions system systemcall test testautomation unix user voidmain() wab win32 win32api windows.h





