mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

What GUI toolset are you using?

Most GUI toolset will have a kind of "Canvas" widget which usually has functions for adding shapes like circles, rectangles, lines, text, etc... more or less everything you need to create a simple "Paint" application.

For example, using Qt, there is a framework of classes grouped under Graphics View Framework that will provide all the functionality that you need. They have examples and tutorials available.

As for other toolsets (WinForms, MFC, WxWidget, GTK+, VCL, etc.), I'm less familiar with them, but I'm sure they have similar functionality, often under a name like "GraphicsView" or "Canvas".

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Well, it appears you have two functions here: quizForm::quizForm_Load and quizForm::btnSubmitTest_Click. The first function has 14,243 LOCs and the second function has 35,154 LOCs. My code editor had trouble just doing the copy-paste operations on such large files, I wouldn't imagine a compiler would have an easier time with it.

Before I say anything else, your code is in C++/CLI, this is a different programming language, not C++. (regardless of how much it tries to look like it is) It is more closely related to C# than to C++.

First, those two functions need to be in the cpp file, there is absolutely no reason to have them in the header file. If you don't know how to do that (as I see that you haven't put anything into any of the cpp file in your project folder), then, here it is:

QuizForm.cpp:

#include "stdafx.h"
#include "quizForm.h"


namespace InteractiveQuiz {

System::Void quizForm::btnSubmitTest_Click( System::Object^  sender, System::EventArgs^  e ) {
  // insert all the content of the function here. Just cut-paste, no need to change anything. 
};

System::Void quizForm::quizForm_Load( System::Object^  sender, System::EventArgs^  e ) {
  // insert all the content of the function here. Just cut-paste, no need to change anything.
};

};

and then, in the header file (in the class declaration), you leave only the declarations:

public ref class quizForm : public Form {

   // ... all the stuff ...


    // only the declarations of the Load and SubmitTest functions:

    System::Void quizForm_Load( System::Object^  sender, System::EventArgs^  e ); …
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

That was no joke in the 1980s. I'd start a compile and then read a book.

Well, it's no joke today either. If I compile my entire code-base, it takes about 1 hour 40 min., or 50 min. on 2 cores. Of course, you avoid full re-compilation as much as possible, but it can still mean frequent 15-30 minutes forced breaks (at least, from coding). The way a friend in the computer game industry described it, that cartoon seems quite accurate actually, they even have LAN game servers for Minecraft or Starcraft running continuously because at any given time there are always enough people who have nothing else to do while they wait for their code to compile.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

It's also nice to be a native-code programmer, because you always have an excuse to take a break.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

The largest file I've got is a QuizForm.h file which is almost 2.5 MB and it has 81875 lines of code!

Absolutely insane! I'm speechless. You've let this get way out of hand. You should never have so much code in one file, let alone a header file. A few thousand lines is already excessive, 80 thousand is insane.

Clearly, it seems that you are not using C++'s separate compilation model to your advantage. Generally, in C++, you compile many small source files (cpp files) separately (which know about each other's functions and classes through included header files), and then linked them together at the end, or package them inside static or dynamic libraries. Doing this makes compilation much much faster because the compiler never has to deal with more than a small portion of the overall code, and you only have to re-compile the small parts that have changed when you changed them. Clearly, you seem to be doing the opposite, and you are now suffering the consequences of that.

One possible cause of your problems is simply that the code is too big. You might want to monitor the amount of memory being used by the compiler when compiling your code. Sometimes, if the compiler reaches an out-of-memory condition while running (i.e., it has too much code to analyse), it just slows down tremendously, possibly to the point that it will effectively never finish. I've had that problem before with very heavily templated code where the …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Did you add glut32.lib to the list of libraries?

If it is not installed, follow these instructions.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

As mat1998x said, the limit of 2Gb is probably imposed by the compiling or running environment (incl. the OS). It is possible that compilation in "debug mode" would include a limit like that, under the assumption that undebugged code might have leaks, I would doubt that any compiler would produce such a limit under "release mode". It is also possible that the limit is imposed by the runtime environment, for example, if you ran the program through your IDE's "run" button, then it is possible that the program is actually running in a sandbox environment with extra protections. Finally, it is also possible that your operating system has a limit (probably relative to your available RAM and the amount of RAM required by the OS itself) so that a single user-land application cannot overrun the system by grabbing all the memory.

Another very likely source of the limit is due to the inherent limits of the system. For example, on a 32bit computer, the address values (pointers) can only map up to 4Gb of memory, and, since the virtual address space created by the operating system for the process will often make a distinction between heap-bound addresses (for dynamically allocated memory) and static addresses (addresses to execution points, stack pointers (local variables), global variables, etc.), you need at least one bit to make that distinction, which means you can only map 2Gb of dynamically allocated memory. So, on 32bit systems, the operating system is forced to impose a limit like …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

They are smart only in planting and growing opium poppy.

@Xantipius: They have a choice between growing opium poppy in the hopes of earning a decent living, and growing a normal food crop which they won't be able to sell at a price that can compete with subsidized crops from wealthier nations, meaning they'll run out of money and be forced to sell their land, probably to people willing to grow opium on it. It doesn't take a genius to figure that out... I guess thinking isn't really your department.

They appear as poor (they are but the media makes it worst) but a lot of them are rich people. The rate you find millionares in afghanistan would be more common in america (based off of population).

@<M/>: That's the irony with poverty and wealth, they usually go hand in hand. What every poor country has in common is a population of obscenely rich people. Here, in Quebec, we have many very rich people who immigrate here out of very poor African countries (old French colonial countries), either permanently or for their college studies. This is just the tip of the iceberg. Most of these poor countries function with a massive population of poor people who work hard and ear very little, then some foreign corporation that is sucking them dry, but you always have a strata of local millionaires who work either as the cogs of the corrupt government or as local pawns for the …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

But we really thought that we brought into this country the kindess and socialism.
Then it will turn out they need NO our help and services.
They want make heroine only. Nothing more. They are stupid animals.

I suggest you study history a bit more carefully than that before making bigoted statements like that.

The two biggest periods of growth of opium cultivation in Afghanistan were during the Soviet occupation and, now, under the US occupation. There was an opportunity for the Soviet government to make a lot of money by taxing the opium growers for the money they made from selling their opium in Russia (through Kazakhstan). Basically, they figured they couldn't stop the trade so might as well invade the place, make the trade an interior business, and collect estate taxes from the opium growers. They went in and highly encouraged more farmers to grow opium, and got the Russians addicted to heroin by a massive inslot of inexpensive merchandise, especially in Novokuznetsk and other cities bordering Kazakhstan. It's a good way to scrape every last penny from your people's pockets (whatever they had left or managed to hide from the USSR government).

When the Afghans were left alone, they made modest efforts to reduce the production, and eventually the Taliban took more drastic measures and reduced the production by nearly 90%. Of course, when the US came in, pretty much the first thing they did was to reinstate the opium production to meet …

<M/> commented: Another good post from a poster I respect +0
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Thanks for the clarification, the whole bashrc / bash_profile / profile business is confusing sometimes.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

He can download the Open Source version that Some Guy wrote, install the compiler, check the settings and build it, or, he can buy the Windows version for £9.99 and it does what he wants, near enough.

Most of open-source Linux software can be downloaded and installed from the repositories in a single click (or a single command on terminal). In my experience, it is far easier to install most open-source software in Linux than in any other OS. Even free software in Windows is annyoing to install (download the installer, run it, click "next" about a doxen times, wait for an incredibly long period of time, and then, possibly restart), and I'm not even talking about the stuff you need to buy at a store or pay-download-validate online. Where do you think the idea of having "app stores" came from? It's a direct copy of the software distribution model that has been used in Linux for ages.

Linux is too complicated and whilst we techies might like that, the average computer user can barely figure out that the internet isn't a program on their computer (Okay that's very sweeping generalisation but I'm sure you get my point).

There's been a lot of progress in that department. If you use a main-stream distro like Ubuntu, Mint, Fedora, OpenSUSE, Android or Google Chrome OS, there's not much that is "too complicated" about it, although if it isn't pre-installed, it does require a bit of tech-savvy or you …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

What I want from an IDE are, mainly:

  • A good set of text-editor functions and have them easily accessible. By text-editor functions, I mean things like find-replace, goto-line, file search, and so on.
  • A good set of basic coding aids like syntax highlighting, code formatting (indenting), maybe collapsable blocks, and so on.
  • Quick and responsive code-completion. I cannot stress enough how important that it should be quick and responsive, otherwise, it's useless.
  • Good interaction with cmake.
  • Integration of version control systems is a bonus (Git, SVN, etc.).
  • Integrated documentation is also a bonus.

In that sense, I'm a bit of a minimalist (not quite as minimalist as rubberman). I generally find it impractical and wasteful to have too much stuff in one massive tool (cough.. Visual Studio.. cough..). When you program, you don't do 50 things at once, so why have 50 different tools in one IDE, it's just clutter. I've used Visual Studio quite a bit, but never more than a tiny fraction of it, and it generally fails for me at the most basic things listed above (even its text-editing functions are awkward compared to the "norm" of basic notepad-like editors, code-completion is too slow and must be turned off, and unsurprisingly it doesn't seem integrate well with anything). On the opposite, CodeBlocks does perform quite well on most points listed above (although its code-completion could be a bit faster). My favorite IDE is definitely KDevelop (works on all OS except Windows), it's great at …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Apparently someone liked her.

A lot of people liked Hitler too.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Normally, you should have sudo privileges. In that case, you can run any commands you want under root-privileges by writing sudo before it, like:

$ cd /sbin/
/sbin$ sudo mkdir test_dir
[sudo] password for YOUR_USERNAME: 
/sbin$ cd test_dir
/sbin/test_dir$ 

To actually switch the root user within a command terminal (for all subsequent commands), you can do sudo su (i.e., su means "super-user", another name for "root" user). Simply as so:

/sbin$ sudo su
[sudo] password for YOUR_USERNAME: 
/sbin#

(notice that the dollar sign becomes a # sign when you are logged as root. And you type the command exit to go back to normal user account. Of course, this only applies to that terminal session.

As root user (through sudo su) you can also change the root password with the command passwd. Afterwards, you can login as username "root" and with that password. However, it is not recommended to ever do that. You should just use sudo whenever you need to do things that require root privileges, and use sudo su occasionally when you want to do many root-privilege commands.

As for setting things like the PATH variable, these things are usually set in the .bashrc file in your user's home folder. This is a kind of "loading personal settings" file. There are also other files for that, I'm not sure anymore which.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

These lines will certainly cause a stack overflow:

const int SIZE = 500000;
string s[SIZE];
int test[SIZE];

This creates (stack-based) static arrays of integers and strings, of 500000 elements. Assuming you run this on a 32bit platform, this will probably take about 10Mb of memory (and probably twice that on a 64bit platform). The stack is a static and limited amount of memory to be used for local variables of functions as they are needed, it is not meant to be used to allocate large arrays like that. Typically, the limit of the stack is between 2Mb and 8Mb, depending on the platform and compiler (the stack size can usually be configured via a compiler option, but the default is usually about 2-8Mb).

For any kind of large arrays, you should allocate them dynamically, even if you know their size at compile-time. So, you can use either these C-style arrays:

int main() {
  const int SIZE = 500000;
  string* s = new string[SIZE];
  int* test = new int[SIZE];

  // the rest of the main() function's code here.

  delete[] s;
  delete[] test;

  system("pause");
  return 0;
};

Or, you can use the following C++-style vectors:

#include <vector>

int main() {
  const int SIZE = 500000;
  vector<string> s(SIZE);
  vector<int> test(SIZE);

  // the rest of the main() function's code here.

  system("pause");
  return 0;
};

The stack overflow is gone, but the program has been running for well over 5 minutes and isn't completed. This seems …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Linux shot itself in the foot by trying to make everything open source and free a philosophy they try to extend to people developing for their OS. This is a pipe-dream. The world runs on money and that isn't going to change (even if currency in a decade is in potatoes, there will always be "money").

It's true that the "world runs on money", but it's not true that open-source software does not. In many cases, open-source software is software developed by stake-holders (people who need and use the software) either directly or by funding people to do it. For example, the "code-aster" project is a complete suite of finite-element analysis software, which is a kind of advanced engineering software, the kind that is used to analyse the internal stress in structures or aerodynamic flows. In this field, companies typically have to pay in the order of tens of thousands to hundreds of thousands of dollars for a single license of such a kind of software, and often it is hard to find one that has the features you need in your company. So, a few research institutes and large companies got together and funded an open-source project "code-aster" to build a complete suite so that they could all use it and extend it with what they need. At the end of the day, instead of paying the license fee for some expensive commercial software, they pay the development cost directly, and then get a software that is …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

@pixelsoul, It must have hurt when your father took that picture.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I was in Baltic Sea just a few years ago (maybe 10 years ago) on a USA flag fising factory ship doing some work for the company I worked for. We were about 200 miles from Alaska shore, no one mentioned mines in the water. Perhaps they are just on the Russian side of the sea???

That doesn't make any sense. How can you be in the Baltic Sea and within 200 miles from Alaska's shore? I think you're confusing the Baltic Sea with the Bering Sea.

Ancient Dragon commented: You are right +0
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Nomatter who you are or who she was, everyone should give the dead respect.

There is a fine line between respecting the departed for the sake of their family and loved ones, and creating an unfairly glorified picture of a person just because they passed away. At any point in the last decade, you could have asked me what I thought about Thatcher and I would probably say her policies were absolutely terrible and destructive for the UK, and that she was probably one of the worst prime ministers to take office. And now that she passed away, am I supposed to have a different opinion? No, my answer is the same.

I couldn't care less that she passed away, I didn't know her personally, and her death doesn't affect me in any way. However, because she passed away, she's in the news and people are talking about her more than usual. And because of that, people with unflattering opinions of her will express those opinions more than they usually do just because they're talking about her more than usual. This is not "dancing on her grave". It's just honest people giving their honest opinion, which hasn't changed just because she died, why would it?

I much prefer that kind of honesty to people who try to somehow cobble together a massive silver lining and say only nice things out of "respect" (either don't say anything or give your honest opinion), or even worse, those who use this …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Oh and about pronounciation Click Here a sound not found in English. Enjoy!
Edit: just noticed you're from Quebec somewhere, so you know the sound I guess, so you would not pronounce déja vu as dejavou

Yeah, I definitely cringe a bit every time I here the borrowed "dejavou" expression used in English. It's weird that English doesn't have this letter even though most of its root-languages have it: French / Dutch has it (written as "u") (all latin languages have it too), all scandinavian languages (even Finnish) have it (written as "y"), and German has it (as "ü").

I had a professor once who spent the better part of an hour trying to tech me how to pronounce pouilly fuisse.

Pouilly-Fuissé (proper spelling). Wow, your teacher was a sadist. I even have trouble pronouncing that. I guess it is something like Poo-(ee)-yee Fü-ee-ssay (where "ü" is of course that extremely common sound that does not exist in English for some weird reason, can't even think of an English word that has a sound remotely like it). I understand you have trouble, I think it contains many of the things that anglophones have trouble with: the "ou-i" and "u-i" diphthongs, the "ill" sound (kind of a diphthong of "i" (or "ee", but short) and "ll" (like "y" in "yes")), and obviously, the letter "é" which all anglophones have trouble with (like "ey" in "hey!", but shorter and higher).

When I am told to make …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

My first name is Daniël, but all my friends call me Danny.

I would have thought people would call you Dan (much more usual short for Daniël, at least, here in Quebec).

here is a song by an italian who immigrated to Belgium long time ago

Nice song. It's a bit weird to here an Italian singing a German-polka song. He must be from northern Italy.

Edit: he's from southern Italy, even weirder.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

What does "retire his account" mean? I guess it should mean that it is deactivated in the sense that it won't "participate" anymore (e.g., doesn't show up on endorsements, cannot send him PMs, etc.). But obviously, all past posts and stuff should remain, probably also the user profile (maybe with a eulogy-like notice).

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

My name is supposed to represent an arch angel, so yeah... AWESOME!

Yeah, there is the arch-angel Michael (or Mikael, or Mikhail, or Michele, or whatever translation) from abrahamic religions (judaism / christianity / islam). But, apparently, it also literally means "who is like God", which is even more awesome! We're pre-destined for greatness!

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I have no clue how to pronounce "Sven", maybe like "seven"???

Kinda. Like "seven", if you omit the first "e", and the last "en" is more like in the word "pen".

So what is the correct (ie your) pronounciation of Mikael? Is it me-KALE, mih-KALE, ME-kel, me-KEL? Am I getting close?

It's something like that I guess (I'm not sure what your options actually mean when you pronounce them). The French pronounciation is "me-KA-l" (you say the "l" like you would if you were saying the alphabet), in other words, "me" like the English word "me", "KA" like in "cat", with emphasis on the "KA" syllable, and then a separate "l" like in "bell". The Swedish pronounciation is more like "MEE--kel", that is, an emphasized "ME" like the English word "me" with the last vowel stretched out a bit, followed by a slightly aspirated short pause (to be accurate), and then "kel" like the word "bell" but with a "k" (in other words, the "a" is silent, although some may pronounce it as part of a diphthong with the "e"). I think the most trouble for English speakers is to separate the "KA" and the "l" sounds of the French pronounciation, and also putting emphasis on the middle syllable seems difficult too (in English, emphasis is usually either none at all, or on the first syllable).

I thought it was always pronounced like: "mih-Khail"

That sounds more like the russian Mikhail. There …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Overall, I'd have to say Unix. It's the basis for virtually all the main operating systems used today. It's architecture has stood the test of time. Apple's operating systems were always somewhat based on Unix and have now (with OS X / iOS) crawled back home to the Unix family (POSIX-compliant). Even Microsoft has finally made modest moves in that direction (e.g., getting a bash-like shell with PowerShell, and adopting a more Unix-like user-privilege system), i.e., kind of retro-fitting some Unix-inspired elements. And, of course, GNU/Linux and BSDs are essentially (open-source) implementations of Unix, and now dominate every market (servers, clusters, embedded systems, phones, tablets, routers, DVRs, etc.) with the exception of laptop/desktop PCs.

I know that this is a bit of a cop-out, like answering "what is the best car" by saying "the internal combustion engine car" (which is includes virtually every car built in the last century), when clearly the question asks for the best car brand and/or model. But I like to say Unix, because it has the benefit of, for once, putting Microsoft alone in a corner with no friends, and once you frame it as Windows vs. Unix-family-and-friends, there's no competition.

I guess you should narrow down what you mean by "best operating system". If a discussion (or flame war) is to occur, you would probably need to narrow things down to "highest quality personal computer operating system", otherwise, being inclusive, there isn't much debate to have, except maybe between GNU/Linux and BSDs.

So, I …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I was thinking of using sockets. Thread A prints and sends a message to thread B. Thread B prints and then sends a message to thread A. Any thread before printing checks for the message from other thread and prints only if they have received the message.

You have the right idea, but the wrong channel of communication. Communicating thread notifications through a socket is terrible from a performance point of view. All operating systems or multi-threading frameworks will provide a number of different types of thread synchronization mechanism to do this kind of thing. There are a number of approaches that could solve your problem. One solution is a condition variable which basically allows one thread to notify another of a condition. Another is a synchronization barrier which allows two threads to have a "meeting point" that both must reach before any one of them can continue. You could probably also solve your problem with a pair of mutex locks, but be wary of dead-locks. For faster operations, you can also use atomic operations on volatile flags. I think that's enough food for thoughts.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

How Can I Restricted The Movement Of The Cursor And Determined At Which Point/Pixel User Hit Any Key..!!

As you record the key-strokes to move the cursor, first check that the movement is allowed (remain within the ranges of x and y values), and, of course, keep track of the coordinates of the cursor, you can use those coordinate values when you get the "hit any key". Please show your code if you want more detailed explanation.

Graphics In C++ Are Much More Difficult As Compared With Python, Java, C#...!!

The difficulty mainly comes from the fact that graphic user interface libraries are not part of the standard library in C++ (as they are with some other languages). Being primarily a general-purpose system infrastructure programming language, having a GUI library in its standard library would be a really bad idea. However, there are many external libraries that can be used in C++ for this purpose, most of which are just as easy to use as in other languages, in fact most of the GUI tools of other languages are written in C++ with a thin layer that give you access to them.

Is There Any Way To Learn About C++ Graphics Within 3-4 Weeks That Are Enough For This Game..!!

It would seem to me like basic console graphics is probably enough for this game. The thing is, what you can do in the console is quite limited, so I guess you want to …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

You need to use your setX and setY functions to set the new positions, as so:

                    if (inputEvent.Event.KeyEvent.wVirtualKeyCode == VK_DOWN)
                    {
                        if (maze.CanPlayerEnterSpace(person.GetX(), person.GetY() + 1))
                            person.SetY(person.GetY() + 1);
                    }
                    if (inputEvent.Event.KeyEvent.wVirtualKeyCode == VK_UP)
                    {
                        if (maze.CanPlayerEnterSpace(person.GetX(), person.GetY() - 1))
                            person.SetY(person.GetY() - 1);
                    }
                    if (inputEvent.Event.KeyEvent.wVirtualKeyCode == VK_LEFT)
                    {
                        if (maze.CanPlayerEnterSpace(person.GetX() - 1, person.GetY()))
                            person.SetX(person.GetX() - 1);
                    }
                    if (inputEvent.Event.KeyEvent.wVirtualKeyCode == VK_RIGHT)
                    {
                        if (maze.CanPlayerEnterSpace(person.GetX() + 1, person.GetY()))
                            person.SetX(person.GetX() + 1);
                    }
                    break;

The way you had it before, as this:

                        int p = person.GetY();
                        if (maze.CanPlayerEnterSpace(person.GetX(), person.GetY() + 1))
                            p++;

didn't work because the variable p is not referring to the y coordinate in the person object, it is a separate variable, so, when you do p++;, all you are doing is incrementing the p variable, it does nothing to the y coordinate of the person object.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Or maybe IP = Internet Packet?

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I have the same problem as Rev. Jim, my names are Sven Mikael. Mikael is the given name I go by, and Sven is my forename, like a middle name (not used) but that goes before my given name, which is usual in Sweden, but not in Canada, where I live and grew up. And like Jim, every form I have to fill in will either allow just a first name or first and middle names (or initial), I never know what to do, I would usually put Mikael as the first name, and just omit Sven. Still, that gets annoying, and sometimes troublesome. And this is also constantly a problem for all Swedes because the forenames are pretty useful, because in Sweden there is a rather small set of common first names, and a rather small set of common last names, so, any given first and last name combination often yields hundreds of people with the same name, so it becomes pretty useful to use the forename to differentiate. For instance, when working at ABB (Swedish robotics company), there were 3 other employees in the email-system called Mikael Persson. When I got stopped at security in a US airport, they had more than 200 files to plow through that had my name (since they couldn't allow forenames in their database), I was stuck there for an hour.

I would say that the only thing I don't like about my first name is that it's often hard for people to …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Categorizing C++ as an OOP language is very reductionary. C++ is a multi-paradigm language. C++ was originally motivated by the OOP "revolution", and that played a major part in its original popularity. In modern times though (21st century), the popularity of C++ is mostly driven by what Alexandrescu calls "zero-overhead abstractions", or as Stroustrup puts it "an uncompromising infrastructure language". In other words, C++ is remarkably effective at allowing you to create high-level abstractions with minimal overhead, that is, you don't have to make compromises on the performance in order to construct the kind of complex software designs that are needed in certain complex applications. In large part, this is because it allows you to move very freely between the simple-yet-effective procedural programming style (i.e., C-style POD-types and free functions), the dynamically-flexible object-oriented style, and the highly customizable, zero-runtime-overhead generic programming styles (i.e., the STL), and blend them all at your heart's content.

Today, "competing" languages are sort of stuck in the niche that they dug themselves into. Of course, some high-level languages like Python do not pretend to compete with C++, but rather embrace the complementary role that they can play (i.e., providing simple-to-digest and flexible wrappers for what is mostly C / C++ code running under-the-hood). But others, particularly Java, are pretending to compete with C++, especially in the field of infrastructure programming. They generally rely on arguments of being less complex / easier to learn, on providing more flexibility, runtime safety and portability, and on the idea …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Innamorato is an italian word, the correct transcription is with two nn, so innamorato not inamorato.

It's a borrowed word. It's borrowed from the italian "innamorato", but in English it is spelled "inamorato" and means "a male lover", as opposed to the more general italian meaning of "lover". This is again one of these annoying borrowed words that change meaning and spelling, which is terribly confusing when you actually know both languages.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

There are a few ways to solve this problem reasonably quick. They generally depend on how much memory your are willing to spend (i.e., the classic computer science lesson: memory-complexity can often offset time-complexity).

The "slow" method, as you described, is to go through all faces and then for each of them go through all the other faces to find a match. This algorithm has a time-complexity of O(N^2) where N is the number of faces. This is pretty much as slow as it can get, but requires no additional storage besides the storage for the mesh and for the output.

A better method hinges on the fact that the core operation that takes time is "looking for the match". If you are going to look through all faces for a potential match, this is O(N) and since you do that look-up N times, this gives you that O(N^2) complexity. However, you can build a search tree to accelerate the look-ups by using the fact that the matching face probably belongs to a polyhedra that is reasonably close to the one to which the first face belongs to. If you have a search tree that allows you to quickly obtain a small neighborhood of polyhedras, then that dramatically reduces the possibilities for a matching face. Typical search trees used for this kind of thing are called space partitioning trees (e.g., Kd-tree, octree, and many others). In general, you can resolve such nearest neighbor queries in O(log(N)) …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

First of all, only non-static member functions can be declared as const. The const-ness applies to the object on which the member function is called, that is, the object and thus all the data members it contains. Here is an example:

class Foo {
  public:
    int bar;

    void member_func() const;
};

void free_func(const Foo& f);

void Foo::member_func() const {
  bar = 42;   // ERROR: data-member 'bar' cannot be modified, it is part of a const object.
};

void free_func(const Foo& f) {
  f.bar = 42; // ERROR: data-member 'bar' cannot be modified, it is part of a const object.
};

int main() {
  Foo f;
  f.member_func();  // calling 'member_func' on the object 'f'
  free_func(f);     // calling 'free_func' on the object 'f'
};

So what is the difference between making the agrument constant and making the function itself constant?

As you see from the above example, nothing is different. Qualifying the member function as const is just the way to tell that the first hidden argument to the function (which is the object on which the member function is called) must be treated as const within the function.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Oh what a tangled web we weave,
When first we practise to deceive!

-- Sir Walter Scott

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Wednesday, April 17, 1985

Yes.. it's my birthday today!

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Wow.. this is hard to pin down, I've been mostly programming as a hobby and now using my skills as a tool for doing robotics research. I mean, it's always been all about challenging myself with impossible tasks, now my job is to solve impossible problems. So, I have no interest in simple problems.

I think that one of the more complex things, in the sense Xantiplus means it, that I did, and I mean that was the most complex to do relative to my skill level back then, was when I was playing around with procedural generation of natural textures, objects and landscapes for 3D games. I was just too lazy to use a 3D model editor to create anything, so I set out to use these super-complicated algorithms to generate everything randomly. The hardest tasks were probably either generating natural-looking blends of ground textures depending on the shape and altitude of the points of a randomly-generated landscape, or, managing to render a dynamically per-frame re-blending of high-definition moving sky textures at 300fps (and that was about 12 years ago, so no shaders, no multi-texturing (all software blending), etc.). I was in high school back then, it was way over my head, but I managed to get most of it working.

The most laborious was definitely my undergraduate thesis. I created this full-fledged high-fidelity multi-body dynamics simulator in order to do continuous contact dynamics simulation (i.e., when multiple objects are sliding against each other, one of the hardest things …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

One fun moment was during my senior year advanced math classes. When we were doing exercises, which is to say, when the rest of the people were doing exercises while I was hacking together an RPG game in assembly language for my TI-83 calculator. As people started having trouble and lining up at the teacher's desk, some realized I wasn't too busy so they started to direct their questions to me. Soon after that, the teacher was a bit embarassed when more people lined up at my desk than at his. Me FTW!

Also, some time after graduating, I learned through the branches that the number one super-achiever in my high school was absolutely obsessed with trying to beat me at everything, i.e., he was going around collecting information (via his friends) to keep track of the grades I was getting in each exam and stuff, he really wanted to finish first of the class, which he did, after a lot of time spent studying. Given that I never had to put much effort at all to get good grades, often far less than my average-grade friends, I count that as a win. I think I must have finished somewhere in the top 5 students or so (they didn't say, it's not customary to rank people like that here). And the award for finishing first was 100$ (pathetic, I know... we're not big on merit awards in Canada), but I got a special 300$ award as a university credit because …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I would like to find out why is it not necessary for a method to declare an exception when coding in C++?

Actually, now with C++11 (latest standard), it is more than just "not necessary", it's deprecated (compilers must still accept the code, but it's highly discouraged to use explicit exception specification in your code). This is essentially a case of "lots of pain but no gain".

Specifying the exceptions that can be thrown by a function can't really accomplish much beyond just causing a hard crash if an unspecified exception is ever thrown. And because the whole thing is a dynamic mechanism (run-time), there is a run-time overhead to it and no benefit in static code optimization (like in the case of noexcept where the exception-handling code can be removed entirely) which is where traditional "native" languages like C++ shine. So, that was the "no gain" part.

In Java, since it sits at a higher level, it can have checked exceptions and can actually optimize accordingly (although modern exception implementations don't benefit from this), and the run-time overhead is eliminated by resolving this at compile-time. If C++ wanted to do the same, it would have to get further removed from native linking formats (e.g., ELF) and would have to specify at least some, if not all, binary interfaces (ABI) which it currently does not (and that is a huge move to make, and a widely debated and argued topic too). One of the advantage of designing a …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

There are a number of problems with your code.

First, if you are going to define the multiplication operator as a member function of the class template, you need to make it a const function:

// the prototype in the class template declaration:
double  operator*(const TinyVector<T_numtype, N_length> &) const;  //<-- notice 'const' here.

// the definition:
template <typename T_numtype, int N_length>
double TinyVector<T_numtype, N_length>::operator*(const TinyVector<T_numtype, N_length> & x) const  //<-- notice 'const' here.

This makes the object on which the member function is called const, just like the other operand (x) which is const too, which makes sense in a multiplication.

Second, why do you return a double? Why not the value-type of the vector itself:

T_numtype operator*(const TinyVector<T_numtype, N_length> &) const;

For example, if you created a TinyVector< std::complex<double>, 3>, then you would have trouble returning just a double from that. And if you had int, you would be doing an unnecessary conversion.

Third, it is usually discouraged to make operator overloading (and overloading in general) as member functions. This is because it can have some awkward quirks with regard to overload resolution (argument-dependent lookup), and hiding rules. It is also annoying when it comes to heterogeneous types, because you just can't use member functions only if you want to support both orderings of operands. So, unless a function is clearly only related to the one object on which the function is being called, prefer to use either a free function or a free friend …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Why would they be? All you did was recite a line from the internet, hardly romantic. Plus the whole pick-up line concept is fairly demeaning to women since the implicit assumption is that you don't care about getting to know her as a person you just want to get her to bed as quickly and with the least emotional input/effort on your part as possible.

There might be a few idiots out there who think that, but I think they're a small minority. Nobody thinks that a pick-up line is a one-sentence path to getting a girl to hit the sack with you, that's ridiculous. I don't think many people actually expect a cheesy one-liner to sway a woman romantically either, regardless of how mesogenistic someone is, you can't possibly think women are that easy / stupid. Even the few women that do seemingly get picked-up by a one-liner are knowingly doing so, e.g., they're just looking for a one night thing, and yes, sometimes that's all a woman is looking for too, my mother and her sisters used to have this expression when they were younger: "going fishing for skin" (from French: "aller pêcher pour d'la peau"). Guys don't have the monopoly on shameless pleasure seeking.

In general though, pick-up lines make for good light-hearted comedy, and I think they're more demeaning of men if anything. They're probably more used in sit-coms / comedies than in real life. And if you use them in real life, I …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I wrote my programs on paper blocked out for 80 characters that I wold then hand over to the students taking keypunch class who would punch my program into cards so I could take them to operator who would take the card deck and put it into a queue for evnetual running after hours in batch mode and i would get a listing of all my errors the next day so that I could rinse and repeat.

That got me thinking about today. If you work on any typical mid-size project, then you write code in a certain style dictated by the project guidelines, usually including a maximum of 80-120 characters per line. Then, you send a request to your project manager to have your code merged to the main branch. He evaluates your code, merges it, and sends it off for a complete build and test suite, and the next day you get all the error and conflict report such that you can "rinse and repeat".

I guess the more things change the more they stay the same. Except that we no longer need to immerse our computers in a vat of lubricant, thank goodness for that!

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

The O() means "of the order of". Generally, a function is of the order of its biggest term, i.e., the term that, as n becomes very big, dominates all the others, in other words, the only term that really matters for large values of n. So, if f1(n) = A*n + B*n^2, then it is of order n^2, so you would say that f1 is O(n^2), i.e., g1(n) = n^2. So, just think of g1 as "the largest term of" f1. If the function is now f3(n) = f1(n) / f2(n), then the corresponding g3(n) should be the largest term of f3(n). The question asks to demonstrate that the largest term of f3 is not going to be g1 / g2, i.e., the largest term of (f1 / f2) is not equal to the largest term of f1 divided by the largest term of f2. It is a rather straight-forward demonstration to make.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Engineering is a very down and dirty profession, the theory of how an internalcombustion engine works, and dismantling and re-assembling a nice clean college workshop engine is good practice, but cannot compare with a ten year old, poorly maintained breakdown in the street.

Kinda off-topic, but this got me thinking of a fellow student during my mech-eng undergraduate days. He had a "genius" idea to theoretically increase the air-flow to his engine by inserting a computer cooling fan inside each outlet of his intake manifold. In practice, of course, the plastic melted almost instantly and spewed all over the valves and the inside of the cylinders, he had to buy a new engine. I just thought I'd share this with a fellow engineer. At the time he told us what he had done, I thought it was the stupidest thing I had ever heard someone do, I still think so today.

someone has to give jobs for the newly qualified to get experience

I agree with both of you, there needs to be opportunity for people with no experience, but not all companies have the latitude to provide that. It can be a good payoff, or a quick jumping point.

when would you feel that you're at a point where you would say that "you know this language"?

I would second Agilemind on that. I would tend to describe my knowledge of languages as either "familiar with", "proficient at", or "expert in". You can …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Here's an even more geeky one:

Hey.. what's your API? Cause I'd like to make a dynamic link with you.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

(Disclaimer: do not try this one if you don't like to get slapped in the face)

"Do you work for a jeans factory? [Why?] Because you're working your way up a ply in my pants."

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Jim: But to be honest, most of what I say is not worthy of scrutiny.
..
ddanbe: But as in real live I'm not going to look for weapons, illegal drugs etc., I'm surely not going to do that on the web. So as far as me is concerned, everything I've put on the web may be seen by everybody.

I always feel a bit queezy when I hear what is essentially the "it's OK cause I have nothing to hide" argument. Why do people have opaque walls to their houses, why do they put up curtains, why do they surround their property with a fence or bushes, if they truly consider that it is OK for other people to know everything that they do, since they got nothing to hide. I think that equating the need for privacy with the desire to hide your criminal activities is a false equivication.

First, it generally makes the assumption that the only reason why anyone might look into your private business is to discover criminal activity. The reason there are warrants is because the law is structured as: if you want to look into someone's private business to discover criminal activity you suspect, then get a warrant, if you have any other reason to look into someone's private business and you do so, be prepared to go to jail. That's how the "it's OK cause I have nothing to hide" perspective is resolved by the law and how …

GrimJack commented: I'm with you on this -it drives me crazy +0
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I was just roaming the internet for some interesting reads and I came across this very interesting paper about how to define a legal framework for the "reasonable expectation of privacy" when it comes to our new cyber-existence. I thought I'd share it with you guys, and see what you think about agencies being able and allowed to collect and analyse huge amounts of data about any individual they like.

The main point of the article is that the conventional wisdom that says that when you roam outside, in public places, you can't expect privacy (i.e., people (incl. authorities) could be watching what you do) doesn't work when it comes to roaming the cyber-world (visiting sites, blogging, chatting, posting on forums / leaving comments / tweeting, etc.) because, in that world, people can collect and analyse all of your actions (past and present) as a whole and this way, they can infer so much about who you are, what you do, who you associate with, what your views are, etc..., that it amounts to things that anyone would consider to be their "private business". And in most countries, private citizens (and by extension, companies) are not allowed to look into other people's "private business" too much (i.e., it's illegal, and usually a felony), and authorities are not allowed to do that either unless they can show "probable cause" and obtain a warrant.

Currently, many agencies and private companies are taking huge liberties in this regard, enjoying the legal …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

AFAIK "rank" cannot be bought. It must be earned.

I wish that could apply to politics too.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

You have to understand something about security. User privileges are always a single point of failure. If somebody comes in (remotely or physically) and obtains privileges that he shouldn't have, then there really isn't much you can do about it. Encryption is not going to help with that problem at all.

You need to organize user accounts smartly, protect user-credentials from being disclosed or easily obtained. That's the true recipe for security.

Each workstation (presumably operated by some person) has a user account for that person. That personal user account should have read-write privileges only to its samba mirror (to where it uploads daily changes). But that user account should not have any access to the other samba directories (backups for other users). Then, you have, on the samba server machine, a high-privilege user (super-user) that has read-write privileges to all of the samba directories. Then, you can do the rsync backup to the other remote machine through that super-user account (on a nightly cron job) (and encrypted communication prevents an attacker from eavesdropping).

If an "attacker" somehow obtains the credentials (user-name and password) of one of the workstation's user accounts, all he'll have access to is that user's files (which is the minimal damage you can expect). If he somehow obtains the super-user credentials for one of the backup machines, then there's nothing you can do, he can grab whatever data he wants, encryption is not going to change that, regardless of the scheme you employ.

Encrypting the hard-drive …