D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] C++ Questions?

 

Hi Anthony

I will get a copy of the book you mention, I do have a few books, But i find 
i have to start coding before it really sinks in.And learn the hard way.
Do you know if the book covers mainly std libary code, so code is more 
likely to compile on Linux or windows?

Thanks again for all your help and advice


Regards

Sam

----- Original Message ----- 
From: "Anthony Williams" <anthony@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
To: <list@xxxxxxxxxxxxx>
Sent: Monday, March 23, 2009 9:44 PM
Subject: Re: [LUG] C++ Questions?


> At Mon 23 Mar 2009 20:19:01 UTC, Sam Grabham <sam@xxxxxxxxxxxxxxxxx> 
> wrote:
>
>> Have i miss understood how to use .h files with .cpp file work?
>
> Yes.
>
>> When searching the web i have found some users are putting all there
>> code into the .h files.
>
> Making all your functions inline in the .h file removes linking issues.
>
> Firstly, in C++, the string type is "std::string", not just plain
> "string". It lives in the <string> header. The <cstring> header is
> entirely separate, and contains functions like strcpy for operating on
> C-style char* strings.
>
> Secondly, in C++ you specify the type before the variable name. Your
> fileinfo.h should thus look like:
>
> #ifndef FILEINFO_H
> #define FILEINFO_H
>
> #include <string>
>
> // prototype
> class fileInfo;
> int fileProperties(std::string fileName);
> bool IsDirectory(std::string);
> bool RemoveDirectory(std::string);
> #endif
>
> From looking at the .cpp file, it appears you expect the functions
> declared in the header to be member functions of your fileInfo class.
> As declared, they are not, they are "free" functions which are not
> members of any class.
>
> At this point I suggest you buy yourself a copy of "Accelerated C++"
> by Koenig and Moo, published by Addison Wesley. It's currently 1/3 off
> at Amazon:
> http://www.amazon.co.uk/Accelerated-Practical-Programming-Example-Depth/dp/020170353X/
>
> Anthony
> -- 
> Anthony Williams
> Author of C++ Concurrency in Action | http://www.manning.com/williams
> just::thread C++0x thread library   | http://www.stdthread.co.uk
> Custom Software Development         | 
> http://www.justsoftwaresolutions.co.uk
> Just Software Solutions Ltd, Registered in England, Company Number 
> 5478976.
> Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK
>
>
>
> -- 
> The Mailing List for the Devon & Cornwall LUG
> http://mailman.dclug.org.uk/listinfo/list
> FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html


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



No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.0.238 / Virus Database: 270.11.24/2018 - Release Date: 03/23/09 
06:52:00


-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html