siddhant3s 1,429 Practically a Posting Shark
siddhant3s 1,429 Practically a Posting Shark

There are a lot of reasons to love iostream.
Standards don't say that iostream is slower or faster than stdio.
But usually iostream is build by wrapping stdio hence it is usually slower in the current implementations.
Until and unless you have a VERY GOOD REASON to use stdio, I don't prefer to use it.

siddhant3s 1,429 Practically a Posting Shark

ISO C++ need you to explicitly mention the datatype after the 'const'.
At the moment of defining C1, C2 is not defined.
Read http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.11

siddhant3s 1,429 Practically a Posting Shark

I did say that post#3 was an exception.
None of the above has highlighted that the above techniques will not make the matrix contiguous except post#3.

siddhant3s 1,429 Practically a Posting Shark

I would recommend a reading to http://www.parashift.com/c++-faq-lite/freestore-mgmt.html#faq-16.16 for a complete reference.
None of the above has highlighted that the above techniques will not make the matrix contiguous except post#3.

siddhant3s 1,429 Practically a Posting Shark

Another thread where the OP got a pre-cooked pudding(tasteless though).

siddhant3s 1,429 Practically a Posting Shark

Tell me how much time did you spent on a search engine to find your answer.
In technical terms, 'saving' is known as serialization[1]
There are plenty of libraries out there to serialize STL containers. You are fortunate enough that Boost's Serialization Library is there on your demand.
Another library is provided on CodeProject

But I would suggest you to use this tool and find the best library for you, yourself.

[1] serialization is actually the process of converting an object into a sequence of bits so that it can be persisted on a storage medium (such as a file, or a memory buffer) or transmitted across a network connection link.

MosaicFuneral commented: Boost = red -1
Nick Evan commented: Counter red. Not ALL boost is crap +20
siddhant3s 1,429 Practically a Posting Shark

>I won't allow myself to use that as it's just too foreign on a windows machine.
I don't agree.
Python guarantees that the '/' will be converted to whatever underlying platform is using. Hence it is *always* portable to use '/' instead of '\\'.
This guarantee is actually from the fact that C compiler itself use this convention.
So, use '/' and be portable.

siddhant3s 1,429 Practically a Posting Shark

>As you see in the server's response last-modified header is not set. In this
>circumstances, how to force the server to give data only if the cached page at
>user has been modified by the server instead of the server making every
>response refreshed.
Not all server support this facility. This server does, but not for the main page:
Below I am listing the conversation between my browser (firefox) and the website:

GET / HTTP/1.1

Host: www.imdb.com

User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008061015 Firefox/3.0

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Accept-Language: en-us,en;q=0.5

Accept-Encoding: gzip,deflate

Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

Keep-Alive: 300

Connection: keep-alive

Cookie: uu=CX+yLlMGer760ThYKb3rwgcx2n6Ud0w+kURafREkT33RASpdsSQKLdBEfx3x5+1Zxxd6SMe3TD6UZa8dtGfsbeQ0zt3xYcyex0AquAXx2t4xMVrY0DG6KNBRGvi2MVqptzPY3jczCP4z08iuN7cYesX0Xz219G89FfRfXafkXx20hD8eNAQvLbe0Xx3HF0yeMfcMHpdQemjPB0w+lDRPPhR0f33HtF8d1IQ/HjR0Dx0XtF8d1xdMDjH3DB6XUVrpNDdMPpQkb23kNA9d1wfsnYc3TD6XMQqu1DdMPpQEHw3kNA9dxwfsnYc3TD6XF0xu10c8Dp



HTTP/1.x 200 OK

Date: Thu, 02 Jul 2009 08:04:34 GMT

Server: Server

Cache-Control: private

Content-Type: text/html

Set-Cookie: session-id=122.162.244.5.1246521874392211; path=/; domain=.imdb.com

Set-Cookie: uu=dwqwj+qqsAa9zXeKESJ1rwcx2n6Ud0w+kURafREkT33RASpdsSQKLdBEfx3x5+1Zxxd6SMe3TD6UZa8dtGfsbeQ0zt3xYcyex0AquAXx2t4xMVrY0DG6KNBRGvi2MVqptzPY3jczCP4z08iuN7cYesX0Xz219G89FfRfXafkXx20hD8eNAQvLbe0Xx3HF0yeMYcMHpcXTBjUND9+lHQvPRe0Xx3XF0wuMfcMHpdRWuk0V0w+lDQffeQ0D13HB+ydhzdMPpFBGt7XF0x5pBfEHpQEzz2UNA9dxDfsnYQ0z63kNA9d1yfsnYc3TD6XF0xu10c8Dp;expires=Thu, 30 Dec 2037 00:00:00 GMT;path=/;domain=.imdb.com

Set-Cookie: cs=PpPGYbzrkdWZaIY9FQ1IpwiOAiSO2RITtsmaRI1aYWQNukEHnnoBB87ZEhQoWVIEjtkkY9pOkiSIjCE3Hc/BF7mZspfO2SSyblESJI7vJDOO2RIkjvkSJI7ZEmTOiWIUg=;expires=Fri, 03 Jul 2009 07:00:00 GMT;path=/;domain=.imdb.com

Set-Cookie: session-id=769-6521874-9398196;path=/;domain=.imdb.com

Set-Cookie: session-id-time=1246608274;path=/;domain=.imdb.com

Vary: Accept-Encoding,User-Agent

Content-Encoding: gzip

P3P: policyref="http://i.imdb.com/images/p3p.xml",CP="IMDB "

Content-Length: 9819

nnCoection: close

----------------------------------------------------------

http://i.media-imdb.com/images/SFbda806c2716d56596760a49da9112b27/css2/consumersite.css



GET /images/SFbda806c2716d56596760a49da9112b27/css2/consumersite.css HTTP/1.1

Host: i.media-imdb.com

User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008061015 Firefox/3.0

Accept: text/css,*/*;q=0.1

Accept-Language: en-us,en;q=0.5

Accept-Encoding: gzip,deflate

Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

Keep-Alive: 300

Connection: keep-alive

Referer: http://www.imdb.com/



HTTP/1.x 200 OK

Server: Server

Last-Modified: Wed, 24 Jun 2009 07:35:41 GMT

Etag: "4295-4a41d74d"

Accept-Ranges: bytes

Content-Type: text/css

P3P: policyref="http://i.imdb.com/images/p3p.xml",CP="IMDB "

nnCoection: close

Vary: Accept-Encoding

Content-Encoding: gzip

Cache-Control: max-age=314712038

Expires: Sat, 22 Jun 2019 20:05:13 GMT

Date: Thu, 02 Jul 2009 08:04:35 GMT

Content-Length: 3673

Connection: keep-alive

--snipped--

As you can see, the main page …

siddhant3s 1,429 Practically a Posting Shark

>If the code is already there, you might as well help make it better and hope the
>guy learns something instead of sitting on your **** waiting for him to fail at life.

Why not nicely pack in a parcel with automatic installers and send him on his postal address with a Project website built?
;)
Not blaming you actually, but it was the post before yours which was the culprit.

siddhant3s 1,429 Practically a Posting Shark

About namespaces, Tom Gun has written an excellent post. Read it http://www.daniweb.com/forums/post903119.html#post903119

siddhant3s 1,429 Practically a Posting Shark

>What langage is reflection possible? atleast without a lot of difficulty?
Python and Lisp as far as I know.

siddhant3s 1,429 Practically a Posting Shark

Yes, it is not possible. But ask your self: you you really need it? I never felt need of such a thing. The only close alternative is to use a std::map something like this:

int main()
{
  using std::map;using std::string;using std::cout; using std::cin;
  map<string,int> m;
  m["i"]=1;
  m["k"]=5;
  m["ok"]=53;
  string input;
  cout<<"Enter a variable name";
  cin>>input;
  cout<<"You entered "<<m[input];
}
siddhant3s 1,429 Practically a Posting Shark

Copy constructor is invoke when you initialize an object with another.
In this case, it will be invoked something like this:

LDAPControlSet a;
//do something with 'a'.
LDAPControlSet b=a;//copy constructor invoked with 'a' as the argument
LDAPControlSet c;
c=b;// copy constructor *not* invoked but initialization operator invoked
LDAPControlSet d(a);//explicit invocation of the copy constructor with 'a'  as argument

When this copy constructor is called, it simply copies the content of the std::list cs::data to its own std::list data.
In the above example, a is passed as parameter to the copy constructor's parameter cs.
cs.data is the std::list of that argument
and data is the std::list of the own object.

siddhant3s 1,429 Practically a Posting Shark

"[ CODE ] and [ /CODE ]" without the spaces.

Next time you can use the noparse tag to tell the exact usage.

[noparse][noparse]

bbTags are not parse with this tag. Even if you type [code][/code] it will appear as it is. This example was created using two noparse tags.

[/noparse][/noparse]

siddhant3s 1,429 Practically a Posting Shark

>Though people prefer using atoi() which is not a standard and which is basically
>the "C" way of doing it
atoi is as standard as the stringstream solution. The only problem is that it is not that 'good'.
By good means that as the stringstream solution will rely on the standard iostream library, it will tend to be more robust.
One have plenty of good reasons to choose iostream rather than the C cstdio which are listed here.

The stringstream is elegant albeit slow. But as the rules says: `` Don't care about small optimization until you profile your code"

My final advice : use string stream in general and use atoi if speed is an issue.

siddhant3s 1,429 Practically a Posting Shark

You can do something like this:

int myints[] = {16,2,77,29};
  vector<int> fifth (myints, myints + sizeof(myints) / sizeof(int) );
siddhant3s 1,429 Practically a Posting Shark

Aladdin's Magic lamp.
2 Burgers, 1 Large pizza with extra cheese and a diet coke.

Sh*t, nothing is working. This website is junk

WaltP commented: What the heck does this post mean? Is it to make the OP feel bad? Wasn't J's post enough to get the point across? -4
siddhant3s 1,429 Practically a Posting Shark

>search is a standard name declared in the <algorithm> header. It's a very bad
>idea to use standard names even if you don't include the header because other
>standard headers could include it.
Indeed, This is why you are advised to explicitly qualify the names of a namespace rather than using the 'stupid' "using namespace std;" on top of your program file.


>thanks for the help now it says undefined reference to
>search::find(char*,char*). does that mean my return statement doesn't match
>up?
Are you compiling your implementation CPP as well?

g++ main.cpp header.cpp -o out
siddhant3s 1,429 Practically a Posting Shark

You should be using some sort of linear data-structure ( an array or a vector). Consider an array:

Arr         _______________________
    Pos:    | 0 | 1 | 2  | 3  | 4 |
            |___+___+____+____+___|
    Value:  | 1 | 5 | 10 | 23 | 8 |
            |___|___|____|____|___|

We find the largest number by the following algorithm:
Algorithm to find the maximum MAX of an array of length N.
1. Initialize: Set k=0 and MAX to Arr[k]
2. Check: Check if Arr[k]>Arr[k+1]
2.1 Yes: Set k=k+1
2.2 No: MAX=Arr[k+1]. Set k=k+1
3 Check overflow: Check if k==N-1
3.1 Yes: STOP
3.4 No: Go to Step 2

Hence you get the MAX as the largest value.

Always post your code in the post tags:
[code=cplusplus] //your code goes here

[/code]
PS; Did anyone noticed that I am quite good at making pictorials using simple ASCII characters?

siddhant3s 1,429 Practically a Posting Shark

>On the downside: no more time for office-sword-fighting
This reminds me about the cover of the Dragon Book
[img]http://www.stewart.cs.sdsu.edu/cs524/spr08/bookCover_51XtGJ64tZL._SS500_.jpg[/img]

Nick Evan commented: Haha +19
siddhant3s 1,429 Practically a Posting Shark

VernonDozier, here is a sweet link : http://www.codecogs.com/components/equationeditor/equationeditor.php

@jephthah
I got the exact formula. But I thought if I could somehow get a closed term for that summation.
This formula will surely be O(sqrt(N)).
But hey, I think that there cannot be a closed form of this. (If it was, it must have been so obvious)

VernonDozier commented: Nice link +17
iamthwee commented: yes good link +21
siddhant3s 1,429 Practically a Posting Shark

>I'll try to help you to the best of my abilities, and if I did help you, please add to my
>rep ;D
ROFL.
I think begging is against rules or something isn't it?
Even I would have put that to my signature if DaniWeb could redeem those points with equivalent dollars ;)

siddhant3s 1,429 Practically a Posting Shark

Always use the size_t type for indexing a container, or for container size.
That means
-> instead of for ( int j = 0; j < item.length(); j++) use for (size_t j = 0; j < item.length(); j++) -> instead of

int size= 5;
int* x= new int[size];

use:

size_t size=5;
int* x= new int[size];

size_t is the alias name for a unsigned integer type depending on your platform.
size_t may be unsigned int or unsigned long etc.
Using size_t indicates that your code will be more portable,

tux4life commented: The actual thread solver! Including some valuable information in his post as well :) +10
siddhant3s 1,429 Practically a Posting Shark

Congratulations, Your code is rusted!!
That means it uses the style of coding that was used aprox 13 years ago. You are using all the deprecated and non portable headers. You are using void main, which is a sin.
In short you are practicing everything that a Standard C++ developer should not.
I bet you would be using the old, crappy, good for nothing Turbo C++ compiler.

Here is [URL="http://siddhant3s.googlepages.com/how_to_tell_rusted_cpp.html"]a guide[/URL] which helps you to migrate to Standard C++ (the C++ which we use today)
If you are a school student, and your teacher teaches you rusted C++, you may still learn the standard C++ and use the rusted counterparts in your school.

The proper code tags are:
[noparse][code=cplusplus]
your code goes here
[/code]
[/noparse]

which needs a lot of help.

What do you mean by 'lot of help'? We won't be correcting and rewriting the program for you. If you are unable to find the errors in such a trivial code, consult [URL="http://www.daniweb.com/forums/thread70096.html"]a good text book[/URL] about C++

And as a Side note, did you bothered to read:
[URL="http://www.daniweb.com/forums/announcement8-2.html"]Announcement: We only give homework help to those who show effort [/URL]
[URL="http://www.daniweb.com/forums/thread78223.html"]Read Me: Read This Before Posting[/URL]

iamthwee commented: "This document is a very briefed guide to check whether your coding practices in C++ are standard or not and to provide possible fix for the same. " Hi kiddo, if you don't speak English I would suggest getting someone who does to check over your work -4
Salem commented: More pith from the "iamtheweener" +36
siddhant3s 1,429 Practically a Posting Shark

Is you password correct?
Next time you say "It doesn't work", post the code were you trying so we can simulate it on our machines.

siddhant3s 1,429 Practically a Posting Shark

In python 2x, print is a statement, not a subroutine, subprogram, or function.
Hence it exists as part of core language. That is, it is integrated as part of interpreter.

In python 3, print is a function which is found in builtins module (but I am not sure since I don't use python 3)

siddhant3s 1,429 Practically a Posting Shark

>It's practically the same thing, in my example I used a struct anyway.
Not in C. A C compiler do not know what a class is.
I agree that struct and class are related ( and they are the same thing in C++ ( except for the default access providers) ) but they can mean a lot of difference to a considerate programmer.
If you meant "class" literally (perhaps you're too close to C++, Never mind happens to everyone :) ), then it is acceptable.
But do remember that C++ structs are not same as C structs

siddhant3s 1,429 Practically a Posting Shark

>I'm just implying that what goes around comes around.
Thats clears it, (Tux, you were right)


>His response implies that he cares enough to bait me into a flame war.
My response implies, that I don't suggest OP to choose M$. And I have justified my self enough. I don't want to caught you in a flame war. You want to stick with M$, fine go with it. It won't rust OP's C++.

BTW, OP has already chosen his OS (it is a Linux). But this doesn't make me a 'winner' or you a 'looser'.

>He just doesn't like with my opinion and decided to lash out at me.
It is just not like that. I have appreciated you behind your back with other DaniWeb member's. And if you feel I should show it in public, I will surly do on your next good post.
Yes, I didn't liked your care-free attitude about the Standard Coding practices in C++: in some post you said something like this "Don't care about standard much, as long as your code works" on some recent posts. I don't like the idea that programming should be non-standard. Don't take it personally. Please. I would have done so for anyone who said so.

>News flash, if you have extreme views, someone is going to disagree with
>you.
You just demonstrated. I have extreme views about M$ vs Linux.
But that is one of …

siddhant3s 1,429 Practically a Posting Shark

You did not applied my formula correctly.
>>r(9) - r(8) = # of rectangles created using exactly 9 squares, which in this case is
>>2, not 1:
r(9)=# of rectangles created using 9 squares (or less) , which 12
The OP want # of square using n or less squares.
The OP wants r(9)

9 these:
#########
########
#######
######
#####
####
###
##
#

plus 3 these:
 
##
##

###
###

####
####

I think you should check the image posted by op :)
Thanks for your time though/

siddhant3s 1,429 Practically a Posting Shark

I forgot to mention it, yes n=1 is a exception.
The above formula is valid for n>1
I have realized it the moment I created the formula but just forgot to mention it.

Yes r is number of rectangle

siddhant3s 1,429 Practically a Posting Shark

>Linux is only free if your time has no value. - Tom Gunn
Next time, try to elaborate your point so that the other person can comment on it.
What do mean by "your time has no value". And on what basis are you saying that.
Linux is really a good designed OS. You would never understand this because you perhaps know nothing about OS designs. Find a book and read about it.
M$ Windows just have too many security holes/ flaws.
Otherwise, why do you need a antivirus for your M$? We don't need any Antivirus for Linux. Because in Linux, a program cannot do much damage to the core OS until and unless it gains explicit permission. Most of us compile our source ourself. All our softwares are open, that means your can 'see' what is going on.
I don't really want to start a flame war, but this is the truth.
Tell me if M$ delivers any free product ? (free as in "free speech" not as in "free beer"

I agree, I do have a Windows XP on my Virtual Machine, but that is just so that I can test my software on it. This make sure that I make portable software as one can never drop the fact that M$ is one of the most famous OS.

siddhant3s 1,429 Practically a Posting Shark

Guess what!!
I derived a O(1) formula for the same.
If it is your homework, don't try to copy the formula. I am sure you teacher will ask you derive it if you do so.
[tex]r=floor\left (\frac{3\times n}{2} \right )-1[/tex]

where floor() is the greatest integer function
floor(3.2)=3
floor(6.1)=6
floor(6)=6

tux4life commented: That effort is worth a cookie :P +10
jephthah commented: sorry man, that's wrong. it doesn't deserve positive rep. -2
siddhant3s 1,429 Practically a Posting Shark

My question : Do we really need this? Why?
If you are needing to open 100+ files at once, you should perhaps re factor your code and design.

BTW, if you are on *inx (Unix,Linux), you can run the following command to know what is the maximum number of open file descriptors:
Note that $ is my shell prompt.

$ cat /proc/sys/fs/file-max
95141

Hence, there can be at most 95141 possible file descriptors opened at once.
To change this use: where 104854 is max number which you want.

$ echo "104854" > /proc/sys/fs/file-max

To check how many of file descriptor are been used;

$ cat /proc/sys/fs/file-nr
5024	0	95141

The first number is total allocated file descriptors (the number of file descriptors allocated since boot)

siddhant3s 1,429 Practically a Posting Shark

Linux is(and based on) one of the most well-designed operating system, while M$ is one of the most ill designed operating system. But this fact is realized only after you start using Linux.
Linux is free, open source. M$ is costly (over rated)
Linux of course has more of a developers environment.
If you are serious into hacking (not cracking. Hacking and cracking are two most common confusable. Cracking involves breaking into computer security systems while hacking involves rigorous problem solving and programming adventures), you should definitely be using a Linux.
The whole of (at least most of the) the Internet runs on Linux.
If you follow the advice of me ( or a good hacker), switch to Linux NOW.
The best candidate will be Ubuntu Linux 8.04 LTS.

As much as programming in C++ is concerned, it doesn't really depends on what OS you choose: you should be able to deliver computer system for most of the popular OSs. But Linux will add 'energy boosters' to your 'milk shake' of programming.

How to Become Hacker suggests Linux
RMS suggests Linux
And many more hackers do.

Tom Gunn commented: Linux is only free if your time has no value. +0
csurfer commented: Hey sid here's your rep back with an extra point,good one there on MS bro...Hail UBUNTU !!! +2
siddhant3s 1,429 Practically a Posting Shark

" .h files are smaller than .cpp " is a convention and a strong convention.
There are many well established libraries which do not follow this convention. One of the infamous example is Boosts; they have header-only libraries. (well, mostly)

siddhant3s 1,429 Practically a Posting Shark

Cheesey,
You sure need to have a reading on this page. It is written by one of the most profound hacker, Eric S Raymond : How to ask question the smart way.
Please go and read it first before attempting to seek any help.
I specially like to quote a paragraph :

Never assume you are entitled to an answer. You are not; you aren't, after all, paying for the service. You will earn an answer, if you earn it, by asking a substantial, interesting, and thought-provoking question — one that implicitly contributes to the experience of the community rather than merely passively demanding knowledge from others.

You do not have any excuse that you didn't knew about code-tags. Information about code-tag is posted all over the website :
1) in the Rules you were asked to read when you registered
2) in the text at the top of this forum
3) in the announcement at the top of this forum titled Please use BB Code and Inlinecode tags
4) in the sticky post above titled Read Me: Read This Before Posting
5) any place CODE tags were used
6) Even on the background of the box you actually typed your message in

tux4life commented: Agreed! +9
Salem commented: Well said! +36
iamthwee commented: hi chicken, I think u need ta work on yer grammer, or if u r having problems get someone ta read over your work, especially if ur gonna post it on the internet! tnx +21
siddhant3s 1,429 Practically a Posting Shark

@MSDN>Essential skills made easy! Written by Herb Schildt
The Art of C++ guy!!
I read that book, and didn't liked it.
bullschildt!!

I personally don't prefer any tutorials to learn C++ from scratch. A Book is a book.
Accelerated C++ is my fav for beginners.

siddhant3s 1,429 Practically a Posting Shark

You can exploit the multiplication operator for strings "Hi"*2="HiHi" .

The solution is pretty trivial and is a one-liner:

>>> for a in range(7): print "*"*a
... 

*
**
***
****
*****
******

Now modify this code so that it can print the pattern you want.

siddhant3s 1,429 Practically a Posting Shark

Well, I know that guide was not exhaustive. It was not a reference material, it was just a guide.
I clearly mentioned that you will have to search for more information about specific topic on the web.
Learn to use a search engine well. There is a sticky thread about C++ books.
My personal favorite are Accelerated C++ ( non-free ) and Thinking in C++ ( a free book by Bruce Eckels)

Though I myself prefer books, you may want to start with a tutorial. But do what ever, stay away from short guides like Sams " Teach yourself C++ in X days" <-- stay away from such guides.

Also read How to Ask Question the Smart Way the link is here.

siddhant3s 1,429 Practically a Posting Shark

Well o Well,
I know that book (since even ) and the only advice which I can give you is "Burn that S**t". Seriously, that book should be labeled "How to teach crappy c++ to students."
But I know that your school and even the CBSE (a central body in India which conducts Secondary and Senior Secondary Examination) sets its question paper in accordance with that book. It is a sad story that bright minds are getting infected by that book.

I wrote that guide exactly for you people, that is who know the pre-historic C++ but want to convert to standard C++. As far as your school is concerned, you can do what I did:
I carried on my practices in Standard C++. Used Standard Compiler. The project I submitted was even not compatible to Turbo C++ ( it was written in g++). But I know that if I wrote standard code in examination, I would get a big zero. So I let those idiots ( that is : my teacher at school, the paper setters, and the checkers) have what they wanted and wrote the pre-historic version in the examination itself.
Believe me, it is not that hard. Just practice the standard C++ while you are at home, and write non-standard code when your teacher asks. It is not at all difficult. Besides, you will find that the quality of your code will increase exponentially when you will use standard C++.

siddhant3s 1,429 Practically a Posting Shark

Not so fast. Although the solution provided works well, always ask yourself why do you need to know the name of the class?
typeid() is a slow construct, it is evaluated at runtime. (Though the most compiler optimize it so as it can be determined at the compile time. This usually applies to object which do not emits polymorphism and complex inheritance)

Also note that type_info::name() will not yield same result on different implementations. My implementations prints 1A due to following code:

#include<iostream>
#include<typeinfo>
class A{};
int main()
{
    A a;
    std::cout<<typeid(a).name();
}

So, the bottom line is, that you shouldn't be needing type_info until your doing some dirty (albeit serious) work. Can we know why do you need to know the name of the object at the runtime?

siddhant3s 1,429 Practically a Posting Shark

Others suggestion is right and should fix the code.:
1. change the "B.h" to A.h while including in the 1st line of B.cpp
2. You are calling f() without an object. Note that f() is a member of B so you need to create an object of B and call f()
Thus, you B.cpp should like:

#include "A.h"
#include <iostream>
using namespace std;
 
void B::f(A a){
    cout << a.x;
}
 
 
B::B() {
}
 
int main(int argc, char argv[]){
    A ex;
    B b;
    b.f(ex);
 
    return 0;
 
}

Compile like this : g++ -o out B.cpp A.cpp

siddhant3s 1,429 Practically a Posting Shark

C/C++ are considered best for system level programming.[1]
You should be using some more abstract language like Python ( I strongly recommended this language: its heaven ).
Strictly speaking, Python, C/C++ (in general all the well-designed languages) do not support such operation using just the core language only; you need libraries to work for you.
Nowdays, you get almost every libraries pre-written to do stuff for you; in most of the languages. So, its just matter to find the right library to do stuff for you.
In simple term, use that language, which have a library available to do some work.

[1]: It is just an opinion; although is widely accepted.

siddhant3s 1,429 Practically a Posting Shark

Oh, what a junk piece of codes (Post #1 and Post#3). It is pretty much expected from Turbo C++ users. Your code is rusted. It is the C++ what it used to be 13 years ago. Now the world has changed. Most of the C++ developer use the Standard C++. They will find hard to read/debug your code. I prefer that you should switch to standards right now.
Read this guide to migrate to standards. It suits best to you both.

Goto is another sinful statement to use in your code. Never use goto.

Just to demonstrate the power of using standard C++, look at the program below. It has been written in standard c++ and does the work which you want to accomplish, but in less amount of line and in less amount of time:

#include<iostream>
#include<vector>
#include<algorithm>
int main()
{
    std::vector<int> vec(20);//create a vector of 20 ints
    for(int i=1;i<=20;++i) vec[i]=i;
    random_shuffle (vec.begin(), vec.end());//suffle them randomly
    
    for(size_t i=0;i!=vec.size();++i) 
        std::cout<<vec[i]<<std::endl;
}

Output:

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

But the above code won't obviously run in your crappy old good-for-nothing compiler called Turbo C++.
Please start using a standard compiler. Read the guide for more information.

Edit: I guess I was too slow!! Anyways, the word is deprecated and not depreciated.
Edit2: I forgot to mention a good shuffling algorithm: http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle . Remember it …

siddhant3s 1,429 Practically a Posting Shark

Do you mean how can you pick up a random number from given sequence of numbers?
follow this thread :http://www.daniweb.com/forums/thread198944.html

siddhant3s 1,429 Practically a Posting Shark

SQL and C++ are two completely different language.
C++ is a (real) programming language. While SQL is a query language intended to interpreted by a RDBMS.
In fact, the entire MySQL is written in C++ [1].
What you can do is perhaps call the SQL queries from a C++ program; that will require you to mess up with few SQL libraries (search the web to find a apt one).

[1]:http://www.research.att.com/~bs/applications.html

siddhant3s 1,429 Practically a Posting Shark

@jephthah
Then what should I do? Send a PM to Mr.iamthwee? You think it will work? Don't you there is someone lurking here and spreading his gaucheness around? SoS, am I infected.

@Tux,
LoL, those formula were pretty elementary. Anyone who has taken even a high-school course on Thermodynamics can understand them.

@Salem
LoL X2. You read my mind: I was just thinking to start a thread on the Geeks' Lounge.
I mean seriously, I had nothing personal against him. But everyone has his limit of accepting crap.

siddhant3s 1,429 Practically a Posting Shark

>This would be the equivalent of doing something like...:
No. In the first code, you declared a pointer which is pointing to a memory location. Hence, in this case you will be dealing with a pointer like interface. If the pointer was to object, you would refer to the member of the object as pointer->member rather than pointer.member
To get a variable like interface, you can use references as in:

#include<iostream>
int main()
{
    int* const ip=new int(5);// a const pointer
    int& i=*ip;// i is an alias to *ip
    
    std::cout<<i<<std::endl;
    i=6;// i behaves as if I declared it as int i
    std::cout<<i<<std::endl;
    delete &i;//the only difference is that I have to delete it
        
}

Regarding the scope of the dynamically allocated memory, the pointer will follow the scope rule. Everything will be same as statically defined object but the only difference will be that a dynamically defined object won't be self-destroyed once it become out of scope.

siddhant3s 1,429 Practically a Posting Shark

iamthwee@reputaion box of post#7>O! ALMIGHTY! Like ALBERT EINSTIEN, Make Me Bright, So that I am Able to Kill >Dark, And Make This World Full Of Light

So? What was your point? That was the ending verse of a poem I wrote when I was nearly 12. Sure it is the published at writing dot com if you go and search my name on google.
But what are you trying to convey? Just picking up my random posts and giving infractions. Is it not a means of harassing me?
Other day, I was discussing with a DaniWeb member about your behavior and I told him that you've improved, but I guess I was wrong.

If there was an option to give infraction on your comments on the reputation box, I (and perhaps more people around) would love to. Those comments are to be written so that the person you are giving infraction knows what he did wrong, not to quote random thoughts.
So please, get a life.

Salem commented: The "iamthwee is a douche" supporters club +35