Jump to content

Recommended Posts

Posted (edited)

Please excuse another noob question.

My C++ dll project has become rather large and I would like to

move some of its functions to another cpp file.

I'm a bit confused as to how to properly do that.

I have a variable declared in dll.cpp

int var;

but if I try to use that var in dlltwo.cpp, visual studio cries that it is undefined

in intellisense and undeclared identifier at compile time.

How do I go about this properly?

EDIT:

int var: is declared in global scope.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Posted

Read a book?

You should have a header file defining: "extern int var", and a code file defining "int var". Include the header file in any file that uses that global.

Or code in a way that doesn't require globals.

Posted

I'm not going to buy/read a book, but I always take advice on board..

Then you're going to have to find another board. You've asked a spate of newbie questions the past week. All of which are answered in a book (Even free ones!). Some of them are probably covered by the C++ FAQ, too. I strongly suggest you read the sticky in this forum on books and if you are at all serious about learning C++ then you need a book. To this day I still reference The C++ Programming Language when I have a question about some esoteric feature or the standard library.
Posted (edited)

If you are banning me from asking questions here or suggesting I

don't post on the forums altogether then just be straight and say so

instead of farting about, as I'm not about to engage in a boring

hoo har.

I think the message was clear.

Don't post these type of questions because they are A) Easily answered yourself B ) Easily searchable on Google and C) Suck up time of other forum members unnecessarily and they D) Do not contribute to community.

Go learn the basics on your own. The things that take 5 minutes are not worth bothering other people with.

Edited by Manadar
Posted

Manadar summed it up well. I'll only add, I don't have a problem if somebody wants to ask one or two C++ questions. Even basic ones. Where I have an issue is when that person wants to ask basic question after basic question. Further compounding that is your statement that you will not purchase a book. I paid something like $45 for my copy of The C++ Programming Language. It was worth every single penny and has paid for itself a few times over despite the fact that I am not actually paid to write C++ code. Furthermore, I personally created a thread in this very sub-forum that lists not just paid books but free books I've read on C++ that I found to be useful. I even put a link to the C++ FAQ. Basically I provided all the information I used to learn C++ with all of it (except one book) being free information. Others have posted things I haven't personally verified but may be of use as well.

So in short, if you want to learn C++ there are plenty of resources already listed on this forum to do so. Otherwise, don't bother learning C++ at all because it is not a language you can just half-ass. Well you can half-ass it but then you will suck and need help at every turn and will generally annoy whomever provides that help.

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...