Click here to Skip to main content
15,900,816 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CComboBox Drop-down Height Pin
Santiago Suárez7-Jun-01 5:58
Santiago Suárez7-Jun-01 5:58 
GeneralRe: CComboBox Drop-down Height Pin
Derek Lakin7-Jun-01 22:19
Derek Lakin7-Jun-01 22:19 
GeneralRe: CComboBox Drop-down Height Pin
Deepak Khajuria7-Jun-01 22:38
Deepak Khajuria7-Jun-01 22:38 
GeneralRe: CComboBox Drop-down Height Pin
Derek Lakin8-Jun-01 0:28
Derek Lakin8-Jun-01 0:28 
GeneralFilling of a rectangle with bitmap pattern Pin
7-Jun-01 4:50
suss7-Jun-01 4:50 
GeneralRe: Filling of a rectangle with bitmap pattern Pin
Christian Graus7-Jun-01 13:12
protectorChristian Graus7-Jun-01 13:12 
GeneralIndenting in Chris Maunders Grid Ctrl Pin
7-Jun-01 4:24
suss7-Jun-01 4:24 
GeneralRe: Indenting in Chris Maunders Grid Ctrl Pin
7-Jun-01 5:15
suss7-Jun-01 5:15 
GeneralAccessing Instance & Resource Handle from an Extention DLL Pin
D.D. de Kerf7-Jun-01 4:16
D.D. de Kerf7-Jun-01 4:16 
General_beginthread and MFC Pin
7-Jun-01 4:06
suss7-Jun-01 4:06 
GeneralRe: _beginthread and MFC Pin
Ulf Öhlén7-Jun-01 5:23
Ulf Öhlén7-Jun-01 5:23 
GeneralRe: _beginthread and MFC Pin
Li Lirong7-Jun-01 16:06
Li Lirong7-Jun-01 16:06 
GeneralRe: _beginthread and MFC Pin
D.D. de Kerf7-Jun-01 20:47
D.D. de Kerf7-Jun-01 20:47 
GeneralRe: _beginthread and MFC Pin
8-Jun-01 4:32
suss8-Jun-01 4:32 
GeneralRe: _beginthread and MFC Pin
D.D. de Kerf10-Jun-01 20:50
D.D. de Kerf10-Jun-01 20:50 
GeneralMDI in MFC Pin
7-Jun-01 3:46
suss7-Jun-01 3:46 
GeneralRe: MDI in MFC Pin
Christian Graus7-Jun-01 13:15
protectorChristian Graus7-Jun-01 13:15 
GeneralRunning in the background Pin
GOW7-Jun-01 3:35
GOW7-Jun-01 3:35 
GeneralRe: Running in the background Pin
Chris Meech7-Jun-01 6:41
Chris Meech7-Jun-01 6:41 
GeneralRe: Running in the background Pin
Michael P Butler7-Jun-01 22:23
Michael P Butler7-Jun-01 22:23 
GeneralLinked list help?! Pin
7-Jun-01 3:32
suss7-Jun-01 3:32 
Please help!!

I have been trying to implement a linked list class, and im having a few problems getting my head
around what it needs to do. Here I have the class, I wanted to be able to get at the first and
last elements, and be able to add things to the list.

struct node {
int data;
node* next;
};

class CLinkedList
{
protected:
int returnFirstElement(); // Return first element
int popFirstElement(); // Return and delete first element
int returnLastElement(); // Return last element
int popLastElement(); // Return and delete last element
void addToEnd(int element); // Add an element to end of linked list
void addOrdered(int element); // Adds to correct location in an orderered list
node* nextPtr; // Points to next node

public:
CLinkedList();
virtual ~CLinkedList();
};

And here is the implementation file. Basically Im having problems thinking what these
functions should do, In particular, what should the constructor do in terms of creating a new
node?

//////////////////////////////////
// Member functions....

void CLinkedList::addOrdered(int element) {

}

void CLinkedList::addToEnd(int element) {

}

int CLinkedList::popFirstElement() {

return 0;
}

int CLinkedList::returnFirstElement() {

return 0;
}

int CLinkedList::popLastElement() {

return 0;
}

int CLinkedList::returnLastElement() {

return 0;
}

//////////////////////////////////////////////////////////////////////
// Construction/Destruction

CLinkedList::CLinkedList()
{

}

CLinkedList::~CLinkedList()
{

}

The thing I would usually do in a situation liek this is: node2.next = &node3
but how can you do this as node3 isnt actually created yet - see what I mean?!

Any pseudocode or advice appreciated.

Cheers
Ben

GeneralRe: Linked list help?! Pin
Ghazi H. Wadi7-Jun-01 12:26
Ghazi H. Wadi7-Jun-01 12:26 
GeneralRe: Linked list help?! Pin
Christian Graus7-Jun-01 13:23
protectorChristian Graus7-Jun-01 13:23 
GeneralNT compilation and linking time Pin
7-Jun-01 1:47
suss7-Jun-01 1:47 
GeneralAccessing records through Recordset Pointer Pin
yamini7-Jun-01 1:42
yamini7-Jun-01 1:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.