Hello's all round

Hey Forum!

I have just joined - obviously! I come here fresh from the bruising, rather toxic atmosphere over at SO. I can imagine that forum and the culture behind it work for some folks - but sadly not me. I say this not to vent, but rather to draw a contrast. I hope the CPP forums are perhaps a little friendlier - they certainly seem that way from a little browsing - and also maybe a little more open to COMMUNICATION! Something sorely, sorely lacking a Stack Overflow - odd for a method of electronic communication!!!

ANYWAY!

I am a fairly old chap and programme not for business but to keep my mind sharp. I have been writing programmes for my own amusement in C++ since 1996, although not solidly and hardly at all over the last few years. I also adore Perl and have come to enjoy some VB as well. I do not like C# or indeed any of that .NET CLR stuff. I find Delphi very attractive, especially its melding of VB-style simplicity with near-C++ performance - however the huge size of its executables put me off at the moment. I still tend to programme as if I were having to cope with the limitations of a Pentium 100 and 16MB of RAM!

So far as my 'skills' go - I am an odd mix. I largely taught myself along with some help from Technical College courses. Therefore I know quite a lot about some advanced techniques, but equally have quite a few holes in my understanding of the basics. I have never been able to get a handle on templates or the HP standard template libraries. I am also quite out of touch with the modern language as I have not programmed C++ 'seriously' since 2000. As I say I am do not work as a programmer but try to take my programming as seriously as if I did. I am also always trying to learn and improve.

I hope the forums here are actually open for some honest discussion and sharing of ideas. I look forward to finding out.
Welcome, and if you need help we will always be happy to help. I would say the only time I don't help someone is probably when they are very illiterate and I can't understand what they say or they are one of the "write the program for me" kinds.

As for the templates think of them as "Generic" objects or cookie cutters I guess. Basically you can do something like
1
2
3
4
5
template <class T>
T add(T lhs, T rhs)
{
    return lhs + rhs;
}
and it would work with any object that has the operator + overloaded. Instead of having to make numerous overloads to do the same thing.

The alternative would be something like
1
2
3
4
5
6
7
8
9
object1 add(object1 lhs, object1 rhs)
{
    return lhs + rhs;
}

object2 add(object2 lhs, object2 rhs)
{
    return lhs + rhs;
}


And for the templated libraries they are pretty much just containers that will work with any object. To store a vector or integers you would do std::vector<int> and to store a vector of strings you would do something like std::vector<std::string>
Hey giblit!!!

MANY thanks for the welcome!!!!

I really will have to put some work in to templates as they seem so fundamental to modern C++ programing. I have seen the 'STL' recommended so many times, but just never properly grasped all the ideas. One thing that really frustrates me is I believe you have to put all the code for a templated function or class in to a header file rather than splitting the declarations and definitions between a '.h' and a '.cpp' like normal.

And I agree - when asking for help it is always important to be as clear in your writing and also provide as much information as possible. That was one of my problems with SO - it was actually against the rules to be verbose and try to describe your problem fully...

Another thing I would like to really nail down is the 'controller-view-model' way of programming for Windows. I am going to have a LOT of questions about how to implement that!!! Currently my understanding is all the data of your program forms the 'model', while the structural code to display and update the window WITH that data is the 'view'. Finally the 'controller' is the code which actually tells the 'view' where to put and how to display the data from the 'model'. I think! Soo... You might use a class to store, access/mutate and retrieve the data as the 'model', individual message-handlers as the 'view' and the message-loop/window proceedure which calls these forms the controller.
Gemman Aster wrote:
One thing that really frustrates me is I believe you have to put all the code for a templated function or class in to a header file rather than splitting the declarations and definitions between a '.h' and a '.cpp' like normal.


Actually there is a way that most people follow to do exactly what you are speaking of with templated functions and classes.

Here is a simple example that shows this.

SomeClass.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
template <typename T>
class SomeClass
{
    plublic:
        template <typename Param>
        void someMethod(Param p);

        T someOtherMethod();

    private:
        ....
        ....
}

#include "SomeClass.inl"  // Key thing to note 


SomeClass.inl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
template <typename T>
template <typename Param>
void SomeClass<T>::someMethod(Param p)
{
    ...
    ...
}

template <typename T>
T SomeClass<T>::someOtherMethod();
{
    ...
    ...
}


Basically this allows you to have some code seperation between the interface of a class and it's implementation. By adding in the #include at the bottom it is basically just tacking on the .inl file to the end of the .h file. Hopefully that makes a bit of sense.

The .inl extension also isn't mandatory you could really use any extension you wish to use since the compiler doesn't care what extension it uses. It is just so human's can organize their code better and so we have a hint of what is in the file.

Hopefully this helps out a bit and welcome to the forum :) generally it is quite a friendly place, though the lounge can spark "hot" debates every once in a while.
Last edited on
Topic archived. No new replies allowed.