Laiq Ahmed 42 Junior Poster

ArkM: I am not denying your opinions but the thing is that we should start learning from basics and Programming language has nothing to do with the logic, if you understand the logic then I suggest to use the built-in functions otherwise creating a raw logic is always a good starting point.

Laiq Ahmed 42 Junior Poster

My Bad with the Line

while (ptrFirst) {

Agreed with C99 standard, But the requirement doesn't say anything regarding the numeric separated words. thats why I've implemented the code this way, again your fstream approach is simplest but the thing is that I've tried to use the char* instead of streams provided function.

Thanks.

by the way I didn't compile it.

Laiq Ahmed 42 Junior Poster

Anciant Dragon has given the answer of question you've asked, you asked for What is the Execution Sequence you didn't ask How to find out the execution sequence.

Let me teach you how to find it out.

void EatSpace(char* Pbuffer)
{
	int i = 0;
	int j = 0;
	while((*(Pbuffer + i) = *(Pbuffer + j++)) != '\0')
		if (*(Pbuffer + i) != ' ')
			i++;
}

when the above funciton is called, Compilers will push the PTR Puffer on stack then push the Local variables i and J on the stack.
now the interesting part. while((*(pbuffer+i) = *(pbuffer + j++)) != 0) assignement operator are evaluatted from right to left.
so the above code can be broken as follows *(pbuffer + j++) the above expression is evaluated as follows

take the address of pbuffer add j to its contents and derefer the complete value. increment the j for next execution

you will get some character in that case aren't you?
assign that character to lvalue which is *(pbuffer + i) you can break the above statement now,
lets say right value calculated as 'C' you assign it to left handside so the right handside become 'C' as well which is not equal to '\0'
isn't it
always remember one thing there is still a world ahead
a more better explanation can be provided to you but the thing is that you don't know the assembly and compilers. Sometimes experts …

Laiq Ahmed 42 Junior Poster

Simple replace

for (last = 1 ; last <= first; last++)

with

for (last = first ; last >=1; --last)

replace the above line and every thing is fine.

Laiq Ahmed 42 Junior Poster

I tried a different Approach to achieve the same

char* arr = " Hallo WOrld";
	char* ptrFirst = arr;
	char* ptrIter = arr;
	int nWordCount = 0;

	// Base Condition.
	while (isspace (*ptrFirst))
		++ptrFirst;

	ptrIter = ptrFirst;
	
	while (ptrFirst) {
		
		while (isalpha(*ptrIter)) {
			++ptrIter;
		}

		++nWordCount;
		
		while (isspace (*ptrIter))
			++ptrIter;

		if (ptrFirst == ptrIter)
			break;

		ptrFirst = ptrIter;
	}

	cout << nWordCount-1 <<endl;

Hope this approach will help you understand?

Laiq Ahmed 42 Junior Poster

I think you should look at the below code more carefully and must understand the complexity and map datastructure,

if you've any confusion post, I will explain you in more detail then.

fstream inFile("C:\\Laiq.txt");

	string line;
	std::map<string, int> mapWordCount;
	string word;
	std::string::size_type endWord;
	std::string::size_type startWord;
	while (std::getline (inFile,line)) {				
		startWord = 0;
		while ((endWord = line.find_first_of(" ", startWord))!= line.npos) 
                {				
				word = line.substr (startWord, endWord - startWord);
				mapWordCount[word]++;
				startWord = endWord+1;
		}
	}
	inFile.close();


	for(map<string,int>::const_iterator iter = mapWordCount.begin(); 
		iter != mapWordCount.end(); ++iter) {
			cout<< "The Frequency of word: "<< iter->first << " is : "<< iter->second <<endl;
	}
Laiq Ahmed 42 Junior Poster

Search for the WinInet MFC Wrrapper,

Laiq Ahmed 42 Junior Poster

How would I delete one char from a string?

string aWord = "question?";

while(aWord[i])
	{
	if(isalpha(aWord[i]))printf ("character %c is alphabetic\n",aWord[i]);
	else
		delete[i]aWord;
    i++;
  }

I can give you two ways. one through STL & other through using the strings only

string strWord = "Hello, World!";
	string strResult = "";

	for(size_t idx = 0; idx < strWord.size(); ++idx) {
		if (isalpha(strWord[idx])) {
			strResult += strWord[idx];
		}
	}
	cout<< strResult<<endl;

Another Way

string strWord = "Hello, World! Laiq?";
	size_t pos = 0;

	for(size_t idx = 0; idx < strWord.size(); ++idx) {
		if (isalpha(strWord[idx])) {
			strWord[pos] = strWord[idx];
			++pos;
		}
	}
	strWord.resize(pos);

	cout<< strWord <<endl;

Little more tricky.

Check the remove_if (...)

Hope the above techniques might help you in understanding ?

Laiq Ahmed 42 Junior Poster

What about Buffer Overflow? :P

Laiq Ahmed 42 Junior Poster

By Just Skimming through your Problem statement one can judge its a sorting problem, what you need to do is to analyze which sort will meets your need, if you've small array and planty of space then the following trivial algorithm will meet your requirements. But this trivial algorithm only requires unique element.

Algorithm.
i) Find the MAX of Input Array in O(n) Time.
ii) Allocate the Large Enough Array and Initialize it with -1.
iii) Loop Through the Input Array and increment the counter of output array positions which equates to input_array value.
iv) Print the Ouput Array (where value is not negative).

again this is a tentative solution, you can think of another, I'll prefer if you check the Thomas H Corman Sorting Techniques, which suites your requirement, if you really want to learn the sorting techniques & mathematically inclined you should check "The Art of Computer Programming" By Knuth.

Laiq Ahmed 42 Junior Poster

sorry my mistake, I didn't see the signature of PrintCard

remove your two cout statements with

#
cout << "human has "<< PrintCard(deck[0]) << " " << PrintCard(deck[2])<< endl;
#
cout<<" computer has" << PrintCard(deck[1]) <<" " << PrintCard(deck[3]) << endl;

with

PrintCard(deck[0]);
PrintCard(deck[1]) ;
// whatever card you want to print.

Hope this works :).

Laiq Ahmed 42 Junior Poster

Modify your Shuffle Function and call the PrintCard Function within it

Change the Following Code Segment

//remove the following four lines.
int card1=deck[0];     
int card2=deck[1];    
int card3=deck[2];
int card4=deck[3];

cout << "human has "<< deck[0] << " " << deck[2]<< endl;
cout<<" computer has" << deck[1] <<" " << deck[3] << endl;

to

cout << "human has "<< PrintCard(deck[0]) << " " << PrintCard(deck[2])<< endl;
cout<<" computer has" << PrintCard(deck[1]) <<" " << PrintCard(deck[3]) << endl;

Hope this helps

Laiq Ahmed 42 Junior Poster

PrintCard requires integer parameter and you are not providing one, and the error description shows this as well.

Remove this myBlackjack.PrintCard(); with myBlackjack.PrintCard(10); it will print the corresponding card and suit

Laiq Ahmed 42 Junior Poster

Hi Laid
Thanks for your reply
This is what I have
auto_ptr<SYS_CORRESP_STRUCT> p_str_Corresp = new (SYS_CORRESP_STRUCT);

memset(p_str_Corresp.get(),'\0',sizeof(SYS_CORRESP_STRUCT));

conObj.CopyToDceSYS_CORRESP_STRUCT(p_str_Corresp.get(),pStrCorresp)
and then possible have a constructor to do the copying like

SYS_CORRESP_STRUCT::SYS_CORRESP_STRUCT(SysCorrespStruct*)
{

// code of void CCaslifUtility::CopyToDceSYS_CORRESP_STRUCT() goes here - or just call it
}
also
do u see a potential bug when strcpy() is used instead of std::string types ??

Thanks

Hi ronan,
Basically std::string are preffered over char* due to several reasons you can read many articles on that but again if you can't change it from char* to std::string you can write the adapter for SYS_CORRESP_STRUCT class or you can use the handle body ideom in this case its totally up to you and the scenario. because RPC requires marshaling so some libraries of RPC requires char* instead of std::string and if you are getting the class SYS_CORRESP_STRUCT from that lib you can better write the adapter for better manageability or you can keep it as it, as far as strcpy is concerned I don't recommend you to use strcpy you should use strncpy why ? read about buffer overflow exploit :). and I don't know why you write the strcpy as follows. strcpy((char *)output->record_type,(char *)input->recordType.c_str()); the second parameter of strcpy takes const char* and string function c_str() returns the const char* so no need to cast. if you replace the above call to strncpy if you're not intended to use the strings. then use the following call

Laiq Ahmed 42 Junior Poster

The Question is where you've Created the Test Folder. Place with your code files. it will identify the header file in that folder then.

Laiq Ahmed 42 Junior Poster

in one line answer is

Loanc operator+(const Loanc & l) const;

	bool operator<(const Loanc & l)const;
	bool operator>(const Loanc & l)const;
	bool operator<=(const Loanc & l)const;
	bool operator>=(const Loanc & l)const;
	bool operator!=(const Loanc & l)const;
	bool operator==(const Loanc & l)const;

make all the above functions global or static members.
then call them
just do it and give me the reason why it works now :)

Laiq Ahmed 42 Junior Poster

Basically using operator new for memory allocation has nothing to do with the smart pointers (auto_ptr or shared_ptr), the purpose of auto_ptr is to encapsulate the naked pointer and release the memory automatically when it exists from scope basically there are several objectives of smart pointers. among those mostly used are.
i) ownership
ii) reference counting

in your case I think you just need the wrapper to exclude the explicit delete call, you can write the wrapper like auto_ptr in more appropriate way which most suited your needs and scenarios (multithreaded or not). otherwise check for the auto_ptr implementation again be careful if you pass this pointer to some functions as I told you if auto_ptr is implemented by your compiler as ownership transfer then you must always pass (auto_ptr<T>&) to any function (i.e. reference to auto_ptr) otherwise you'll lost the ownership from main function. Its good to use the Auto pointer

Read any good article of Auto_ptr, but keep in mind the different between delete[] & delete operator provided by your auto pointer implementation.

Hope this helps?

Laiq Ahmed 42 Junior Poster

First question is interesting one, I researched on it, but the below mentioned link has figured out some really good stuff regarding your first question.

http://aperiodic.net/phil/archives/Geekery/find-duplicate-elements.html.

will try your 2nd question tomorrow :).

Laiq Ahmed 42 Junior Poster

What I understand from your question is that, you want your int menu() function to be the entry point of your program, in C99 Standard its defined that the int main() and int main (int argc, char* argv[]) OR int main (int argc, char** argv) should be the starting point of any program in C, but few compilers let is configurable you can change the options and able to set the entry point to another function like int menu or so.
hope I get your question correctly.

Laiq Ahmed 42 Junior Poster

Well ! I don't think you don't know recursion, otherwise you wouldn't have such a good implementation :).

good efforts :).

let's have a expert look on that implementation, hope you'd agree.

I don't like you Copy Constructor's Syntax.

void TreeType<ItemType>::operator=(const TreeType& originalTree);

why? would be your question, let me give your short answer try to find long answer yourself it would definitely improve your concept of copy constructor.

TreeType t1;
....// do some inserting in tree.
TreeType t2;
.... // do some insertion in tree2
TreeType t3;
// now the interesting part.
t3 = t2 = t1;               // what happened here? (if you require description post it).

next is the implementation. don't you think we need to swap these two calls.

92:    CopyTree(root, originalTree.root);
93:    Destroy(root);

The Code of isFull () doesn't check whether the tree is full or not.
Full tree has two childs or no childs. (its simple).

change the implementation of clear.

template <class ItemType>
void TreeType<ItemType>::Clear()
{        
 //         ~TreeType():
             destroy(root);
}

why you are calling destructor in member function ?.
simply replace it with destroy(...).

few more check points are there but first change the above ones ?.
Hope it would help and again printing is simple
pre-order (check your copyTree Implementation (you are traversing the tree in pre-order)).
post-order (check your deleteTree implemenation (you are traversing the tree in post-order)).
last one is in-order. you can do it urself …

Laiq Ahmed 42 Junior Poster

I don't know what your code really does,
I just check the language semantics.

ilc *ob;	
ob=get_activities(ob);

check the codding of get_activities(..), it returns pointer to array of object of type ilc
but within the function get_activities (...). line number 300.

delete [] ob;

and you call delete[] ob in main () as well.

so in some cases your code executes and in some it doesn't well, if it runs on Turbo C++ compiler, I suggest you must change your compiler, use VS 2005 atleast.

Laiq Ahmed 42 Junior Poster

I don't know what your code really does,
I just check the language semantics.

ilc *ob;	
ob=get_activities(ob);

check the codding of get_activities(..), it returns pointer to array of object of type ilc
but within the function get_activities (...). line number 300.

delete [] ob;

so according to my knowledge in some cases your code executes and in some it doesn't well, if it runs on Turbo C++ compiler, I suggest you must change your compiler, use VS 2005 atleast.

Laiq Ahmed 42 Junior Poster

you just need to include

#include <fstream>
#include <iostream>

don't use .h suffix.
also encapsulate the Dragon's function in some class and make that a static member.

and your simplest logger is ready :).

Laiq Ahmed 42 Junior Poster

Hey! you are not considering all the cases, you are finding the sum of link list, NOT SUM IN THE LINK LIST.

let me give you some example.
lets suppose we have a link list containing following element

1, 5, 4, 3, 2, 8.

and I tell you whether the sum 9 exists or not.
yes! 9 exists, node2 + node3 = 5 + 4 = 9.
but in your case the algorithm fails.

Laiq Ahmed 42 Junior Poster

I have interesting solution other than Selection Sort, just for knowledge.
You fetched the numbers from the stream and put it in the array, then sort the array using the desired algorithm.
What if you make a sorted link list and insert in it directly?. just compare the complexities of two algorithm, will give you the in depth knowledge regarding selection sort. [little mathematics required].

check whether you are doing the same thing?

Laiq Ahmed 42 Junior Poster

agreed with niek_e he has given you the good resource for selection sort.

let me discuss what I know about selection sort.

selection sort is simple it just select the element and put the selected element in correct position.
in your case the data is 50, 90, 40.

if you want to sort in descending order.
i) loop on i through the array from 2nd element to end ( make sure your array size is greater than 1).
ii) pick the ith element in key (i.e. 90 in this case its the selected element).
iii) loop on j from (i-1)st element down to zero.
iv) check if key > jth element.
v) yes ! then move jth element to j+1st position. (i.e. making room for 90 in your case).
vi) no! break.
vii). set the key at (j+1)st position.

lets run on your data.
Pass 1.
key = 90.
we start looping on j=1.
checking 90 > 50
yes! moving 50 to 2nd position
j=0, breaks the above loop.
setting key at 1st position.
now array = 90, 50, 40

Pass 2.
key = 40.
we start looping on j = 2.
check 40 > 50.
no ! break.

setting key at 3rd position. (which already was 40).

Pass three, the parent loop breaks. as i == size of array.

so the …

Laiq Ahmed 42 Junior Poster

I think you forgot to push the polygon element in the vertex. first you need to push element in the vector then use vector's at (index) function.
if you want to assign, use array operator instead which returns the reference. and let you add element
like below

m.Polygon.push_back (p);
// or this way.
m.Polygon[0] = p;

Check the documentation of at(..) function which throws exception when trying to access out of bound, it doesn't insert the new element, it is just used to modify the existing one or return the const reference if used as readable member.

Laiq Ahmed 42 Junior Poster

first let me point out some problems in your existing code

//check that price is double/float i.e. 25.5 etc.
double total (int qty, double price)           
{
    double t;
    t = qty* price;
    return t;
}

what ever the total is you need to return the total whether its positive or negative.

But what I don't understand is how you'll read the line and process them? from file stream etc.
well your question requires a bit description, let me help you in what i understand.

S.# Quantity Price/Item Total.
========================
1 2 20 40
2 1 25.5 25.5
Grand Total = 65.5.

Solution.

for the stated problem what you need to do is to read the elements from any souce stream (filestream, or any other form).

if you are reading from file.
then your mile must be well formated like below
1 2 20
2 1 25.5

then what you need to do is to open the fstream and read in corresponding variable.
like below sample code

int main ()
{
   ifstream in ("C:/input.txt");
   int serialNumber;
   int qty;
   double price;
  
   if (!in.is_open ())
   {
              cout<<"File doesn't open"<<endl;
   } 
  
   double total = 0.0;                  // this hold the total of item.
   double grandTotal = 0.0;         // this variable hold the grand total.
   while ( !in.eof ())
  {
       in>>serialNumber;
       in>>qty;
       in>>price;

      total = qty*price;
      cout<<"Item # "<<serialNumber<<" total = " <<total<<"\n";
     grandTotal += total;
  }
    
  cout<<"Grand Total …
Laiq Ahmed 42 Junior Poster

Try Reading Socket Programming.

what you are actually doing is creating a server listening on Port, this can be achieved using WinSock on windows Plateform, same can be done on linux using the socket API defined for linux.

int main ()
{
   // Initialize the Socket Environment.
   // Create Server side Socket.
   // Define Address information & Port.
   // Bind to that information.
   // Start Listening on specified information.
   // Upon Connection Get the Information.
   // Process the Information.

   return 0;
}

hope the above alogirthm might help you.

Laiq Ahmed 42 Junior Poster

Hmmm, Lets do it .
Your Combo must be Owner Drawn.

1. Handle the DrawItem Event of the ComboBox.
2. HICON hIcon = LoadImage (...); // this API will Load the icon(s).
3. Keep the icons in any collection. to fill the ComboBox.
4.In the DrawItem Event
DrawIconEx(...); use this API function... to draw the icon on ith item.

Follow the above steps. I prefer using ATL/WTL classes for the above TASK :). well you can do the same using WIN32 API.

Laiq Ahmed 42 Junior Poster

returning iterator is perfectly valid C++ code. but if you need an object you can derefer the iterator. but the thing is that how will you identify where the object is found or not ( either by returning "" --> empty string) . The semantics of iterator define not found if it returned end ().
Again its upto to you can define the function returning bool stating found / not found. or integer returning -1 if not found and valid index if the string is found in the vector (it defines random access iterator).

StudentRecord r;
vector<string>::iterator found = r.find ("LaiqAhmed");

if (found != r.End ())
{
     // process the found record 
     // string ob = (*found); 
}

// terminates successfully.

// now lets code the End () member function.

vector<string>::iterator End () const
{
     return students.end ();
}

or try returning the index.

int StudentRecord::find(const string& studentName) {
     for (size_t i=0; i<students.size (); ++i)
            if (students[i].compare (studentName) == 0)
                  return i;

          return -1;     // not found
}

The best solutions is using the STL find Algorithm. make the iterator class for your students name, and provide one predicate function. (intermediate solution).

Hope the above things help.

Laiq Ahmed 42 Junior Poster

difference b/w const and #define (macro).

1. Type Checking:- macros are not type safe where as const are type safe. since the macros are replaced by definition at the time of preprocessing (which is done before compilation). the storage area of macros is not defined where as const has static storage area.

for example

#define n  10
int main ()
{
       // what would be the behavior of the below code.
       cout<< &n<<endl; 
       return 0;
}

2. macros are error prune
for example the below code

#define max(a,b)       ((a>b)?a:b)

int main ()
{
     int a = 2;
     int b = 3;
     cout<<max(a++, b)<<endl;
     return 0;
}

check the above code. the proper solution to above is to use templates rather than macros for specifying generic operatoins.
[see. Effective C++ for more details.].

so the conclusion is that use consts & templates where necessary don't use macros. :).

hammerhead commented: Excellent +2
Laiq Ahmed 42 Junior Poster

check the following program

char CalculateGrade (const double percent)
{
	
	if (percent >= 90)
		return 'A';
	else if (percent >= 80)
		return 'B';
	else if (percent >= 70)
		return 'C';
	else if (percent >= 60)
		return 'D';
	else if (percent >= 50)
		return 'E';
	else 
		return 'F';
}

double CalculateAnswers (const string& studentsResponse, const string& answers)
{
	double  score = 0;

	for (size_t i=0; i< answers.length (); ++i)
	{
		if (studentsResponse[i] == answers[i])
		{
			++score;
		}
		else
		{
			--score;
		}
	}

	double percent = (score/answers.length ())*100;
	return percent;
}

int main () 
{
	
	ifstream inputFile ("C:/inputFile.txt");
	ifstream answersFile ("C:/answers.txt");

	if ( !inputFile.is_open ())
	{
		cout<<"File not opened"<<endl;
	}

	if (!answersFile.is_open ())
	{
		cout<<"Answers File not Opened"<<endl;
	}

	

	string answer;				//read from file...
	// Reading the answer from answers File.
	std::getline (answersFile, answer, '\n');
	answersFile.close ();
	answersFile.clear ();

	// Reading the Input File...
	string line;
	string userId, studentResponse;
	while (std::getline (inputFile,line, '\n'))
	{
		// you have student's answer in variable -->studentResponse, and id --> userId.
		std::stringstream inStream(line);
		inStream>>userId;
		inStream.get();
		std::getline(inStream, studentResponse, '\n');
		
		//Compare the answers.
		double score = CalculateAnswers (studentResponse, answer);
		
		// Calculate the Grade.
		char grade = CalculateGrade (score);

		cout<<"The Student :"<<userId<<" got "<<grade<<" grade"<<endl;
		
	}

	inputFile.close ();

	return 0;
}

The answers File contains answers in the form
TFTFTFFFF.

Laiq Ahmed 42 Junior Poster

exactly xsoniccrackersx, I tried to provide you the strings separately now you should modify the algorithm yourself or atleast paste you efforts :).

Laiq Ahmed 42 Junior Poster

Are you using Win32 API, MFC, WTL or Managed C++.

Laiq Ahmed 42 Junior Poster

Lets analyze what the mergesort do.

The first Function you've written

void merge_sort(int low,int high)
{
 int mid;
 if(low<high)
 {
  mid=(low+high)/2;
  merge_sort(low,mid);
  print("decomposed", low, mid);
  merge_sort(mid+1,high);
  print("decomposed", mid + 1, high);
  merge(low,mid,high);
 }
}

it simply spit the array of size n from mid and do it untile (low < high).
if your problem size ( in your case: the size of the array ). is n in the next iteration (when the function is recursed). is (n/2) i.e. first half and (n/2) second half. . the next time function is called it would become n/4 and n/4.

This means what you are doing is
T(n) = T(n/2) + T(n/2).

not lets come to merge.
after the merge_sort return you call the merge function
which compares the two sub arrays, and modify the original one (i.e. it takes n steps) isn't it ?

so the the recurrence relation becomes.
T(n) = 2T(n/2) + n.

Now what we need to do is to solve this (three method exists to solve this relation).
1. Recursion Tree method.
2. Substitution method.
3. Master Theoram.

Solve it yourself. (it required little mathematics).
what you'll get in the end will be n(lgn)+ n + 1.
lg = logarithm of base 2.
The Big O will be n(lgn).

Laiq Ahmed 42 Junior Poster

great stuff to implement. do you understand the cin, stringstream, check to see the functionality they provide, and what they basically are ( HINT: they are specialization of templates ).
if you are good C++ developer then you'll figure out what they exactly do.

typedef basic_stringstream<char, char_traits<char>, allocator<char> > stringstream;

The implement yours.
or if you just want to write it and you don't know about the traits and templates then make the one using buffers.

Laiq Ahmed 42 Junior Poster

paste your database of string file, let me give you the solution.

Laiq Ahmed 42 Junior Poster

Hope the following code. helps.

int main () 
{
	
	ifstream inputFile ("C:/inputFile.txt");
	if ( !inputFile.is_open ())
	{
		cout<<"File not opened"<<endl;
	}

	string line;
	string userId, answers;
	while (std::getline (inputFile,line, '\n'))
	{
		std::stringstream inStream(line);
		inStream>>userId;
		std::getline(inStream, answers, '\n');
		cout<<"The userId is :"<<userId<<" and answers are: "<<answers<<endl;
		
	}
	inputFile.close ();

	return 0;
}
Laiq Ahmed 42 Junior Poster

Hey Sorting is a huge topic and there are several ways of sorting the data.
which technique you want to use to sort this data.
Radix sort can do a job.
lets understand what you want

1 91 25
2 168 20
3 2080 46
4 680 56
5 15 12
6 680 22
7 166 20

you want to start sorting the data from the last two digits.
Algorithm goes like this.
read the list of numbers in arrays.
use suitable sorting algorithm.
the tricky part is how you would get the last two numbers to do comparision (if you are using comparision sorting technique). ? (its simple dear, try gettting the
(number % 100). it will give you last two digits. :).
Perform sorting.


Hope this help.

Laiq Ahmed 42 Junior Poster

well I can see several errors.
I don't know your level of C++, but assume you must be good enough, because you are using STL.

struct attribute { 
	const char* name;
	int id;
};


int main () 
{
	static attribute attr;
	std::string str = "Laiq";
	
	attribute* attrPtr = 0;			//points to nothing...

	attr.name	 = str.c_str ();
	attr.id		 = 4;

	attrPtr = &attr;			// I point to attr here....

	cout<< attr.name<<endl;
	cout<< attr.id <<endl;
	cout<<"The address of Pointer 1 is :"<<attrPtr<<endl;

	str = "Ahmed";

	attribute* attrPtr2 = 0;
	attr.name = str.c_str ();
	attr.id = 18;

	
	attrPtr2 = &attr;

	cout<< attr.name<<endl;
	cout<< attr.id<<endl;
	cout<< "The address of Pointer 2 is : "<<attrPtr2<<endl;

	// Intersting.
	cout<<"The contents of both pointer are same....."<<endl;
	cout<<"The name of Ptr1 is \""<<attrPtr->name<< "\" and the name of Ptr2 is \""<<attrPtr2->name<<"\""<<endl;
	cout<<"The id of Ptr1 is \""<<attrPtr->id<< "\" and the id of Ptr2 is \""<<attrPtr2->id<<"\""<<endl;

	return 0;
}

The above code explains a lot.. try to comprehend what you are actually doing.

Laiq Ahmed 42 Junior Poster

Narue its a part of utility.h in VS2008 and in Utility.h and xstring on VS2005.

Laiq Ahmed 42 Junior Poster

I think J2ME Applications targets wide range of mobiles, while symbian OS has its own (change C++). I will suggests you to use Carbide for symbian development and j2ME ask anyone who knows j2me. I never worked on J2ME. but has enjoyed little development on Carbide :).

Laiq Ahmed 42 Junior Poster

1. avoid using Magic Numbers 6, 12.
make them constants. with meaningfull names.
i.e.

const int MONTHS=12;

2. Associate the pointer with type or identifier not in the middle

double *monthRanking(double * aYearData)

it should be like this

double *monthRanking(double *aYearData)
// OR
double* monthRanking(double* aYearData)

Hope this helps.

Laiq Ahmed 42 Junior Poster

you have problem with Fibonacci heaps or Dijikstra algorithm.

I think you have coded the algorithm using array, so you might getting the problem with fibonacci heaps, paste your efforts regarding fibonacci heaps.

Laiq Ahmed 42 Junior Poster

change line

12:   if(temp!=NULL)

to

12:     while (temp != NULL)

Regards.

Laiq Ahmed 42 Junior Poster

Yes! correct.

Laiq Ahmed 42 Junior Poster

the builtin abs is integer only function.

Laiq Ahmed 42 Junior Poster

what about the following code.

template<class T> 
T const& Absolute(T const& v)
{
	if (v < 0)
	{
		return (v + (-v*2));
	}
	return v;
}

requires minute mathematics.

Laiq Ahmed 42 Junior Poster

I found this regarding nth_element behavior on VC++ 2005.

http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=170789

I think the microsoft implementation has the bug with predicate version of nth_element.