Im new to c++, Ive been plowing through books,web,etc. Many of the things im learning seems redundant but being new as I am I figure that it stems from lack of knowledge. Now finally my questions...Whats the significance of using pointers to reference variables when i could just flat out write[ int k =3;] for example. Question 2 why is so much emphasize on space allocation? My last question is are there things I should learn before attempting to learn c++? ps have attachements I made cant tell the which is better.

Attachments
#include <iostream>

int main()
{
	int month, date,year;

	std::cout <<"Enter the month date year (mm dd yyyy): ";
	std::cin >> month >> date >> year;

	std::cout <<" The date is " <<month << "/" <<date <<"/" <<year; 
return 0;
}





///////////////does the same thing as the other file just less code.
#include <iostream>

struct Date
{
	int month, date, year;
};

Date GetToday(void);
void Digthis(Date);

int main()
{
	Date ag = GetToday();
	Digthis(ag);

	return 0;
}

Date GetToday(void)
{
	Date ag;
	std::cout << "enter date (mm dd yyyy): ";
	std::cin >> ag.month >> ag.date >> ag.year;

	return ag;
}

void Digthis(Date ag)
{
	std::cout << ag.month << "/" << ag.date << "/" << ag.year;
}



///////////////////this does the same thing as the other file just with more context, so how would this be useful??///thx

suppose in your date example that you wanted to make a calendar for all your arrangements the coming year. Let's say you have 200 arrangements already. You're not going to make 200 individual variables, each with different names. Instead, you would allocate room for one big variable containing 200 arrangements, and then simply save the address of this allocation.
In that example it is both clear why allocating memory is important (we are basically just storing information, doing stuff to it, and storing it again. notice how many times "storing" comes up in that explanation), and knowing where we put it.

I know the above explanation is not perfect, but if you start making programs you should soon notice that you care quite a lot about these things.

Miturian, Im starting to see how that would be more effective and less time consuming. If possible could you revise my date file with an example of your own allocating the space for 200 vars. Im hoping I could use it as a study guide.

Fbody im viewing the link you pointed out but it has terms that's unknown to me at this stage in my c++ journey so I just end up deciphering the code that looks familiar not really getting a clear understanding but thx anyway.

>>im viewing the link you pointed out but it has terms that's unknown to me at this stage in my c++ journey
They're the same terms you were trying to use in your OP.

Try this:
Start with this function tutorial, then read the next 5 or 6 pages.

Edited 6 Years Ago by Fbody: n/a

Fbody Ive finished decipher the code from the first link youve referenced. Correct me if im incorrect but it seem to me that its more clean and precise to use pointers allowing functions to use the objects desired without adding size to the code vs making a copy of the object (which can get pretty big) every time i want to be able to use it in my code. Is that the significance of pointers??

That is one significant use of pointers. Yes. If you have the option, it is easier to do it via references. They're not as powerful, or agile, but their syntax is simpler.

There are other uses as well. Such as dynamic memory. Did you read that page in the tutorial I linked you?

YES!!Its is way more comprehensible and has code to try out to give more meaning to the topic being discussed. It makes mention of hexadecimal notation, is that something I needed to learn to be fully versed in c++. If so could you point out a link for that?

Hexadecimal (base-16) notation is actually pretty simple to understand. The representations of the numbers just take some getting used to (like anything else). It just uses 0-9 and a-f (representing 10-15) instead of simply just 0-9 (decimal).

For example:
How do you represent these numbers:

1. Sixteen:
   decimal ([B]base 10[/B]):     16
   hexadecimal ([B]base 16[/B]): 0x10

2. Two-Hundred Fifty-Five:
   decimal ([B]base 10[/B]):     255
   hexadecimal ([B]base 16[/B]): 0xFF

Edited 6 Years Ago by Fbody: n/a

Back to deciphering again...

ex 1. written out in base 16: 0x10 0=number 1, 1= number 2,... F=number 15 correct?

so does ex 2: 0xFF == (0x(15,15)|| 0x(15));

You seem to understand the digits, now you need to figure out the position values.

In decimal notation, 0xFF means [TEX]( (15*16^1) + (15*16^0) )[/TEX] == (240 + 15) == 255

Edited 6 Years Ago by Fbody: n/a

Does 3xBBB = (11*16^4) + (11*16^0) + (11*16^0)?
Also how would (14*16^5) + (14*16^3) be written out?
Like this: 974848?

Edited 6 Years Ago by pharoah85: n/a

ok I understand that but how do i convert decimal to hexadecimal notation?
ie 974848
9x10^5,7x10^4,etc; //decimal
??????//hexa

This question has already been answered. Start a new discussion instead.