Followers 0

# C++ trenches, hpp prototype

## 4 posts in this topic

Converting from FreeBasic (gcc) to c++11 (g++) has gone well, even though c++ feels like a step down

There's just so many annoying things, like the increasingly annoying switch case restrictions, string building, you name it, and god forgive me, old Ansi-C skeletons like || && and yes ^, which is the exponent symbol.

But, now that I've calmed down, let's just say c++ has many nice things too.. for what it's worth

Unfortunately I've gotten myself stuck abit:

In my .hpp file:
..
class Bitmap;
struct voxelmodel_t;
typedef unsigned short block_t;
..
This means, I'm saying there is a class Bitmap, there is a struct blablah etc

Why on earth can't i say: class engine::Bitmap?

The actual problem though:
instantiating Bitmap inside the .cpp now causes the compiler to become confuzzled, since after all,
there's now two Bitmap's, one ::Bitmap, and another engine::Bitmap

So, if i wrote engine::Bitmap there, it will easily refuse me to continue programming, since the two are after all, different!

thanks
only 21k LOC left to convert!
Edited by Kaptein
0

##### Share on other sites

Thanks, i had hoped shortcutting would work, if only for beauty :)

And no, not that kind 21k ;) its C-like code that im.. OO-ing so to speak

Thanks again

0

##### Share on other sites

As a tip though curly braces start on a new line like this:

namespace fubar
{
}


And before this sparks a debate I know this is personal preference but by doing it this way all your opening and closing curly braces should be at the same indentation level in the code. This makes it easier to parse where a block starts end ends for your brain, as you only have to glance at the code to find it.

-4

##### Share on other sites

This makes it easier to parse where a block starts end ends for your brain, as you only have to glance at the code to find it.

I prefer opening braces on the same line. I instantly find where a block begins and ends by looking at it, and it feels natural for me. It all comes down to what makes the developer comfortable (or what makes their employer comfortable).

Likewise, I'm not trying to start a debate, but saying that something strictly opinionated is the right way to go is misleading, especially to someone who is relatively new to the language (especially if they come from one where indentation actually matters in the parsing of code).

0

## Create an account

Register a new account