Function returning pointer to struct
Posted
by
GammaGuy
on Stack Overflow
See other posts from Stack Overflow
or by GammaGuy
Published on 2012-11-13T04:53:45Z
Indexed on
2012/11/13
4:59 UTC
Read the original article
Hit count: 183
I am having some issues with code that is returning a pointer to a struct declared inside a class. Here is my code so far:
SortedList.h
#ifndef SORTEDLIST_H
#define SORTEDLIST_H
class SortedList{
public:
SortedList();
...
private:
struct Listnode {
Student *student;
Listnode *next;
};
static Listnode *copyList (Listnode *L);
};
#endif
SortedList.cpp
#include "SortedList.h"
...
// Here is where the problem lies
Listnode SortedList::*copyList(Listnode *L)
{
return 0; // for NULL
}
Apparently, the copy list method wont compile. I am using Microsoft Visual Studio and the compiler tells me that "Listnode" is unidentified. When I try to compile, here is whhat I get:
1>------ Build started: Project: Program3, Configuration: Debug Win32 ------
1> SortedList.cpp
1>c:\users\owner\documents\college\fall 2012\cs 368 - learn c++\program3\program3\sortedlist.cpp(159): error C2657: 'SortedList::*' found at the start of a statement (did you forget to specify a type?)
1>c:\users\owner\documents\college\fall 2012\cs 368 - learn c++\program3\program3\sortedlist.cpp(159): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\owner\documents\college\fall 2012\cs 368 - learn c++\program3\program3\sortedlist.cpp(159): error C2065: 'L' : undeclared identifier
1>c:\users\owner\documents\college\fall 2012\cs 368 - learn c++\program3\program3\sortedlist.cpp(159): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\owner\documents\college\fall 2012\cs 368 - learn c++\program3\program3\sortedlist.cpp(159): fatal error C1903: unable to recover from previous error(s); stopping compilation
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Help would be greatly appreciated...ASAP
© Stack Overflow or respective owner