1. SImple question about structure and linked list
2. Generating a char* from a linked list of linked lists
Hmmm I might scare people away from this one just by the title, or draw people in with a chalange :) I'm writting this program in c++, however I'm using char* instead of the string class, I am ordered by my instructor and she does have her reasons so I have to use char*. So there is alot of c in the code as well Anyways, I have a linked list of linked lists of a class we defined, I need to make all this into a char*, I know that I need to allocate them into one continuous chunk of data, ie remove all the pointers. The way that I'm currently doing this is by manually placing the data into the cahr* at appropriate placed using sizeof on the objects I'm placing into the the char*. I tried looking up people that were working with dynamic memory and char*'s so see if they were using tokens in their char* then searching for the tokens instead of just accessing the memory locations directly based on the sizeof operator. I am experiencing some mind boggling problems with the way I have it implemented, so I was wondering how other people are implementing a similiar situation. Would it be better to use tokens to seperate the data fields inside the char* or just leave it to pointer arithmatic... This is my first time converting anytype of data structure to a char*, infact I didn't know you could do just cast another pointerto a char* before I started working on this... sooo I'm basically looking for any advice on teh above. Thanks in advacne for any suggestions that are posted.
3. Linked list within a linked list
4. REQ: Help With List Class - Linked List Based
below is what I have for my list class implementation - array based exercise from my book; it works and all.
what I was wondering is if someone could help me out and code a 'link list based' solution to this problem. (adding two numbers and outputing the sum).
thanks very much.
____________________________________
#include <iostream.h>
void reportResults(int, int);
class CharacterPair {
public:
int numberOfQuestionMarks() { return ((ch1 == '?'?1:0) + (ch2 == '?'?1:0) ); }
bool pairMatch() { return ( ch1 == ch2 || numberOfQuestionMarks() > 0); }
bool sentinelPair() { return (ch1 == '*');}
void getPair() {cin >> ch1 >> ch2; }
private:
char ch1;
char ch2;
};
int main ()
{
CharacterPair cp;
int qmCnt = 0, mpCnt = 0;
cp.getPair();
while ( !cp.sentinelPair() )
{
qmCnt += cp.numberOfQuestionMarks();
if ( cp.pairMatch() ) mpCnt++;
cp.getPair();
}
reportResults(qmCnt, mpCnt);
return 0;
}
void reportResults (int qCnt, int mCnt)
{
cout << "Number of Question Marks is: " << qCnt << endl;
cout << "Number of Matched Pairs is: " << mCnt << endl;
}
/*
int CharacterPair::numberOfQuestionMarks()
{
int temp = 0;
if (ch1 == '?') temp++;
if (ch2 == '?') temp++;
return temp;
}
bool CharacterPair::pairMatch()
{
return ( ch1 == ch2 || numberOfQuestionMarks() > 0);
}
bool CharacterPair::sentinelPair()
{
return (ch1 == '*');
}
void CharacterPair::getPair()
{
cin >> ch1 >> ch2;
}
*/
____________________________________
5. Help With List Class - Linked List Based
6. Design question - linked list or std::list
Hello I am modelling a telephone system and I have created a call and a party class. A call can have one to many parties. For example in a conference call there can be 3 or more parties. In a call transfer there can be 3 parties and one of the parties disconnects to transfer the call. I need to be able to traverse the list of parties on each call. for example if each party to the call is disconnected I can remove the call object. I create the call object as a pointer and so I delete when the each party to the call has disconnected. The call object has a std::list of the party objects. Currently, the list is of party objects, not pointers to party objects. I was wondering if it would be better to change the design so that the std::list is of pointers to party. Or even to have the call object create party* 's and the party object to be a linked list - ie a means to SetNextParty(party* next). But if I implement as a linked list I have the hassle of having to delete each party. I would do this when the call* was being deleted. Anyone got any comments on the best approach? A
7. What are best faq for C,C++ and data structures in C links for interviews