Click here to Skip to main content
14,454,504 members

C / C++ / MFC

 
QuestionC++ control textBox of Form1 and Form2 Pin
HeeMongKorea29-Dec-19 21:08
professionalHeeMongKorea29-Dec-19 21:08 
AnswerRe: C++ control textBox of Form1 and Form2 Pin
Richard MacCutchan29-Dec-19 23:02
communityengineerRichard MacCutchan29-Dec-19 23:02 
AnswerRe: C++ control textBox of Form1 and Form2 Pin
Victor Nijegorodov30-Dec-19 1:37
MemberVictor Nijegorodov30-Dec-19 1:37 
QuestionAbstract Factory Design/Linked List Problem Pin
EjireK28-Dec-19 5:59
MemberEjireK28-Dec-19 5:59 
AnswerRe: Abstract Factory Design/Linked List Problem Pin
Richard MacCutchan28-Dec-19 6:51
communityengineerRichard MacCutchan28-Dec-19 6:51 
GeneralRe: Abstract Factory Design/Linked List Problem Pin
EjireK28-Dec-19 7:14
MemberEjireK28-Dec-19 7:14 
GeneralRe: Abstract Factory Design/Linked List Problem Pin
Richard MacCutchan28-Dec-19 7:29
communityengineerRichard MacCutchan28-Dec-19 7:29 
GeneralRe: Abstract Factory Design/Linked List Problem Pin
EjireK28-Dec-19 13:18
MemberEjireK28-Dec-19 13:18 
Thank you for your reply.

As advised, I have worked on a simple linked list storing integer values.

My simple linked list program has add node and display functions. The add node is working fine when the parameters are passed in the main program but the display function only displays the last item added. the other integers added previously are not showing.

E.g for the program below, it only outputs 10 and the other integers are not displayed.

int List::add(int c)
{
	cout << "Adding " << c << endl;
	
	Link* temp;
	
	temp = new Link(c);
	if (temp == 0)
	{
		cout << "Memory allocation failed" << endl;  // shows error in memory allocation
	}

	head = temp;
	return c;
}

void List::display()
{
	
	// pointer 'temp' used to iterate through the list 
	Link* temp = head;
	cout << "Displaying list:" << endl;

	while (temp !=NULL)
	{
		
		cout << "Value of object is " << temp->i <<endl;
		temp = temp->Next;

	}
	
}

int main()
{
	List list;
	list.add(6);
	list.add(8);
	list.add(10);
	cout << endl;

	list.display();
	cout << endl;

}

GeneralRe: Abstract Factory Design/Linked List Problem Pin
leon de boer28-Dec-19 15:53
Memberleon de boer28-Dec-19 15:53 
GeneralRe: Abstract Factory Design/Linked List Problem Pin
Richard MacCutchan28-Dec-19 22:49
communityengineerRichard MacCutchan28-Dec-19 22:49 
AnswerRe: Abstract Factory Design/Linked List Problem Pin
Stefan_Lang6-Jan-20 1:22
mveStefan_Lang6-Jan-20 1:22 
Questionqueues to find minimum time to serve all. Pin
Jiopik27-Dec-19 20:01
MemberJiopik27-Dec-19 20:01 
AnswerRe: queues to find minimum time to serve all. Pin
Richard MacCutchan27-Dec-19 23:01
communityengineerRichard MacCutchan27-Dec-19 23:01 
AnswerRe: queues to find minimum time to serve all. Pin
leon de boer28-Dec-19 15:40
Memberleon de boer28-Dec-19 15:40 
QuestionHow to check if USB filter driver be installed by MFC? Pin
yufengchien26-Dec-19 23:19
Memberyufengchien26-Dec-19 23:19 
AnswerRe: How to check if USB filter driver be installed by MFC? Pin
Richard MacCutchan27-Dec-19 0:44
communityengineerRichard MacCutchan27-Dec-19 0:44 
QuestionKnight move, right direction, dynamic programming to get the maximum cost path from top left to right bottom. Pin
Jiopik25-Dec-19 1:25
MemberJiopik25-Dec-19 1:25 
AnswerRe: Knight move, right direction, dynamic programming to get the maximum cost path from top left to right bottom. Pin
Richard MacCutchan26-Dec-19 5:25
communityengineerRichard MacCutchan26-Dec-19 5:25 
QuestionIRichEditOle::InsertObject shifts text one byte Pin
ForNow21-Dec-19 19:18
MemberForNow21-Dec-19 19:18 
GeneralRe: IRichEditOle::InsertObject shifts text one byte Pin
Richard MacCutchan21-Dec-19 23:07
communityengineerRichard MacCutchan21-Dec-19 23:07 
GeneralRe: IRichEditOle::InsertObject shifts text one byte Pin
ForNow22-Dec-19 6:09
MemberForNow22-Dec-19 6:09 
GeneralRe: IRichEditOle::InsertObject shifts text one byte Pin
Richard MacCutchan22-Dec-19 23:20
communityengineerRichard MacCutchan22-Dec-19 23:20 
GeneralRe: IRichEditOle::InsertObject shifts text one byte Pin
ForNow23-Dec-19 2:04
MemberForNow23-Dec-19 2:04 
GeneralRe: IRichEditOle::InsertObject shifts text one byte Pin
Richard MacCutchan23-Dec-19 3:03
communityengineerRichard MacCutchan23-Dec-19 3:03 
QuestionCASE SOLVED AND CLOSED cout and cerr execute out of coded sequence Pin
Vaclav_21-Dec-19 11:13
MemberVaclav_21-Dec-19 11:13 

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.