JohnOne Posted January 26, 2012 Share Posted January 26, 2012 (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 January 26, 2012 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Mat Posted January 26, 2012 Share Posted January 26, 2012 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. AutoIt Project Listing Link to comment Share on other sites More sharing options...
Richard Robertson Posted January 26, 2012 Share Posted January 26, 2012 Fewer globals lead to better code. Link to comment Share on other sites More sharing options...
jvanegmond Posted January 26, 2012 Share Posted January 26, 2012 Fewer globals lead to better code.No. Fucking. Way. github.com/jvanegmond Link to comment Share on other sites More sharing options...
JohnOne Posted January 26, 2012 Author Share Posted January 26, 2012 Thank you very glad gentleman. I'm not going to buy/read a book, but I always take advice on board. I have read that the fewer globals the better, and I will employ that as soon as I am comfortable with doing so. Cheers. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Valik Posted January 26, 2012 Share Posted January 26, 2012 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. Link to comment Share on other sites More sharing options...
JohnOne Posted January 26, 2012 Author Share Posted January 26, 2012 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. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
jvanegmond Posted January 26, 2012 Share Posted January 26, 2012 (edited) If you are banning me from asking questions here or suggesting Idon't post on the forums altogether then just be straight and say soinstead of farting about, as I'm not about to engage in a boringhoo 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 January 26, 2012 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
Developers Jos Posted January 26, 2012 Developers Share Posted January 26, 2012 .. and as addition to what Manadar already stated: just shut up and leave. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Valik Posted January 26, 2012 Share Posted January 26, 2012 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. Link to comment Share on other sites More sharing options...
Recommended Posts