C Board  

Go Back   C Board > Platform Specific Boards > Windows Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 11-22-2003, 10:13 PM   #1
Registered User
 
Join Date: Nov 2003
Posts: 6
VC++ Sending data from a structure in one class to a ListBox in a second class.

Hello everyone, I'm building a simple RPG type game and have run into a snag with my inventory. The program is a Dialog based application, the problem I've run into is I've created a seperate class to contain all my item handling code and a listbox on the main dialog to display the names of the items. I'm trying to set the items in the listbox by using:

Code:
m_lbInventory.AddString(CItems::PopulateShop(*holder));
and the function code is:

Code:
void CItems::PopulateShop(CString* holder)
{
	*holder = ShopList.m_sName;		
}

The error I receive is:
error C2664: 'PopulateShop' : cannot convert parameter 1 from 'const char' to 'class CString *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast

In that particular case I tried to use pointers in order to get the data, I am not very good with pointers yet and likely did not use them properly. Am I heading in the right direction with the pointers? Or should I be attempting to do this in a completely different way?
Burlock is offline   Reply With Quote
Old 11-23-2003, 08:51 AM   #2
Registered User
 
Codeplug's Avatar
 
Join Date: Mar 2003
Posts: 3,898
Study this and read tutorial
Code:
#include <iostream>
#include <string>
using namespace std;

void set_string(string &ref_string)
{
    ref_string = "setting reference parameter";
}//set_string

void set_string(string *ptr_string)
{
    *ptr_string = "setting pointer parameter";
}//set_string

int main()
{
    string s1, s2;
    set_string(s1);
    set_string(&s2);

    cout << "s1 = " << s1 << endl;
    cout << "s2 = " << s2 << endl;

    return 1;
}//main
Tutorial on pointers

gg
Codeplug is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
data structure design for data aggregation George2 C# Programming 0 05-20-2008 06:43 AM
Screwy Linker Error - VC2005 Tonto C++ Programming 5 06-19-2007 02:39 PM
binary tree token problem OldSchool C++ Programming 13 05-28-2006 10:42 PM
Tab Controls - API -KEN- Windows Programming 7 06-02-2002 09:44 AM
Deleting Data within a Structure or class TankCDR C++ Programming 1 02-01-2002 10:37 PM


All times are GMT -6. The time now is 10:36 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22