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

how do I access "bar" from something like line 43

You can't.

because we were only able to retrieve the variable from the public function, and you could do that anyway?

Yes, but the important thing is that you can only access it through the public function. This is especially important when you are setting the value of it. Imagine you have this class:

class Vector2D {
  private:
    double x;
    double y;
    double magnitude;
  public:
    double getX();
    double getY();
    void setX(double newX);
    void setY(double newY);
    double getMagnitude();
};

Now, at all times, you want the data member "magnitude" to reflect the magnitude of the vector, so, anytime you update the values of x or y, you need to recalculate the magnitude. If you allowed access to x or y directly, you wouldn't be able to do that, but by controlling the access to x and y through these public functions, you can do the following:

double Vector2D::getX() {
  return x;
};

double Vector2D::getY() {
  return y;
};

void Vector2D::setX(double newX) {
  x = newX;
  magnitude = sqrt( x * x + y * y );
};

void Vector2D::setY(double newY) {
  y = newY;
  magnitude = sqrt( x * x + y * y );
};

double Vector2D::getMagnitude() {
  return magnitude;
};

See how I can easily make sure that the value of "magnitude" is always consistent with the values stored in x and y, because anytime the user wants to modify those …

rubberman commented: Excellent explanation of why we use setter methods instead of allowing direct access to member variables. +11
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I understook most of your code, but I wanted to clarify a couple things.On lines 7 and 15 you define "bar", what exactly is the point of doing this when one of them is already public? Thanks again.

Well, my code was just an example for you to understand the difference in where you can access public or private members. And, line 7 and line 15 have nothing to do with each other except that the name of the data member is the same. At line 7, I declare a public data member called "bar" which is a data member of the class called "FooPublic". On line 15, I declare a private data member called "bar" which is a data member of the class called "FooPrivate". These are two separate classes, each with their own data member called "bar". So, it doesn't make any difference that "one of them is already public", the thing is one is a public data member and the other is a private data member, but they are separate data members belonging to separate classes.

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

Welcome!

I've learned most of what I know from YouTube tutorials and some books.

Ditch the youtube tutorials, and make sure your book(s) is good. People who took the time to write a good quality book usually took the time to make their explanations clear and their approach suitable for the learner. People who put together a youtube video tutorial in an hour of spare time usually didn't.

Well, in almost all of those, they mentioned that it was poor programming practice to make all your data members public, inside of a class.

Roughly speaking, that's true. But, of course, as most "rules" in programming, they aren't black-and-white, it's the reasoning behind it that is important, and I think that is exactly what brought you here, so I'm glad for that.

If they are all private, how may I access it from different functions?

Well. That's the point of it all. The private/public/protected are access right specifiers and their purpose is to control from where the members can be accessed. When you create a class, all the data members and member functions of the class can be accessed by any parts of the implementation of that class. When you mark data members or member functions of a class as being private, you make it so that they are only accessible through parts of the implementation of that class, but not anywhere else. When you mark them as public, they are accessible from …

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

It is extremely hard to have any clear idea about what the actual problem is when all there is is a few fragments of incomprehensible code.

Could you create a small test setup that reproduces the error? Like two very small DLLs with only the bare minimum functions to show what you are basically trying to do. The smallest and simplest possible code that reproduces the error (or problem). This way, we can have a clearer and more complete idea of what you are trying to accomplish. So far, from your explanation and your code, I do not understand what you are trying to do, what you are actually doing, or what problems you are encountering.

And, of course, when you are talking about a DLL or cross-modular problem, you must first ensure that all the DLLs are compiled with the exact same compiler (and version), with the exact same settings (compile options), and second, those are details you need to provide.

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

Only problem now is that it says:
Warning: resolving _GLHook_glAccum by linking to _GLHook_glAccum@8

This is only due to the fact that GCC (and other compilers) will generally disregard name-decoration (which is the @8 thing at the end of the name) when matching the symbols. So, it matches the symbol _GLHook_glAccum to the decorated symbol _GLHook_glAccum@8, but it warns you about it because it could be a mistake on your part. With decoration usually signifies that it is __stdcall, without the decoration it usually means it is __cdecl, which are different calling conventions. But these are not super strict rules (it's an old ad-hoc Microsoft rule (how surprising... (sarcasms))), so the compiler only generates a warning about it. To quell the warning you should have the decoration in your def-file symbols (right-hand-side of the equal sign).

I have to use the def file because if I don't use it, how will the original function point to mine?

Yes, renaming the functions to be exported is a valid reason for using a def-file. You could get the same effect otherwise (e.g., making wrapper functions (either in the cpp or header), or using the exported function names directly, i.e., without the GLHook_ prefix), but these are not nice solutions or even appropriate at all. But, renaming the functions in a DLL is not a very common thing that people do, that's why I said that "normally you don't need the def-file". In your case, it makes sense.

triumphost commented: Good Info. I needed that. +0
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

First things to verify:

  • Are all your exported functions marked as having __stdcall as a calling convention?
  • Are all your exported functions (or your whole code) marked with extern "C"?

If both answers are not "yes", then fix that before trying anything else.

Now the above will compile and work flawlessly in VisualStudio but in codeblocks it'll say "Cannot Export Symbols Undefined"..

If it cannot find the symbols to be exported, then that's a problem. First of all, you shouldn't need a def file at all when using MinGW/GCC (the compiler used by Code-Blocks), because GCC exports all global functions that are not marked as static (or don't fall in one of the "no linkage" or "internal linkage" cases). Long story short, everything is exported by default in GCC DLLs.

Second, it is usually easier to write a .def file by first generating it from the DLL or object files. MinGW has a tool for that, it is called "dlltool". You can then use the def file to rename or re-ordinate the symbols when remaking the dll. If you start from that, you should have no more issue of "Cannot Export Symbols Undefined.".

When I do export it in codeblocks, it shows 700 symbols in the DLLExport Viewer whereas the Visual Studio one shows 350.

That is because there are 350 symbols that you specified in the .def file and 350 symbols that are the automatically exported functions. While the MSVC version only …

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

You can try and run this:

#include <iostream>

float arr[] = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};

int main() {
  float* ptr = arr;

  // get the actual "address" that the pointer points to:
  std::size_t ptr_value = reinterpret_cast<std::size_t>(ptr);
  std::cout << "ptr = " << ptr_value << std::endl;

  // if you offset the pointer by 4, you get:
  float* ptr1 = ptr + 4;
  std::size_t ptr1_value = reinterpret_cast<std::size_t>(ptr1);
  std::cout << "ptr1 - ptr = " << ptr1_value - ptr_value << " bytes." << std::endl;

  // check this condition:
  if( ptr1_value - ptr_value == 4 * sizeof(float) )
    std::cout << "The difference between ptr1 and ptr is equal to 4 times the size of a float." << std::endl;

  // if you offset the pointer by 4 bytes, you get:
  float* ptr2 = reinterpret_cast<float*>(reinterpret_cast<char*>(ptr) + 4);
  std::size_t ptr2_value = reinterpret_cast<std::size_t>(ptr2);
  std::cout << "ptr2 - ptr = " << ptr2_value - ptr_value << " bytes." << std::endl;

  // check this condition:
  if( ptr2_value - ptr_value == 4 )
    std::cout << "The difference between ptr2 and ptr is equal to 4 bytes." << std::endl;

  return 0;
};

The meaning of my sentence was to explain the behavior of the above piece of code. Try it for yourself and you'll see.

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

The problem here is that when you add a number to a pointer, it moves the pointer by that number of objects that the pointer points to, not by that number of bytes. Say you have float* ptr;, then *(ptr + 4) is equivalent to ptr[4], meaning that it gets the float value that is 4 floats after the pointer address, not the float value that is 4 bytes after the pointer address. In OpenGL, the stride is specified as a number of bytes, so I assume your "Stride" variables are also in bytes. The way to solve this is by casting the pointer to a 1-byte type pointer, for instance, char*, then do the addition by the stride, and then cast it back to the actual pointer type to retrieve the value. As so:

for (int I = 0; I < TriangleCount; I++)
{
   cout<<"X: " << *( reinterpret_cast<const GLfloat*>(reinterpret_cast<const char*>(Pointer) + (I * Stride) ) ) << endl;
   cout<<"Y: " << *( reinterpret_cast<const GLfloat*>(reinterpret_cast<const char*>(Pointer) + (I * Stride) ) + 1 ) << endl;
   cout<<"Z: " << *( reinterpret_cast<const GLfloat*>(reinterpret_cast<const char*>(Pointer) + (I * Stride) ) + 2 ) << endl;
}

Notice also how the + 1 and + 2 are put after the cast back to const GLfloat*.

triumphost commented: Perfect! +6
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I don't think that would work, try this:

bool x_in_range = (m1.min.x <= m2.max.x) && (m1.max.x >= m2.min.x);
bool y_in_range = (m1.min.y <= m2.max.y) && (m1.max.y >= m2.min.y);
bool z_in_range = (m1.min.z <= m2.max.z) && (m1.max.z >= m2.min.z);
if( x_in_range && y_in_range && z_in_range )
  return true;
else
  return false;
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

The last row should always be (0, 0, 0, 1). That's just the way it is. Look up homogeneous transformations (or Affine Transformations). The last row is there just so that a straight matrix-vector multiplication can be used, as opposed to a special function just for that type of matrix.

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

You can use the is_open() function on the ifstream. As so:

#include<iostream>
#include<fstream.h>
#include<string>
using namespace std;

int main()
{
    ifstream inFile;
    string inFileName;

    cout << "Enter a filename: ";
    cin >> inFileName;

    inFile.open(inFileName.c_str());

    if( ! inFile.is_open() ) {
        cout << "File could not be opened!" << endl;
    } else {
        cout << "File was successfully opened!" << endl;
    };

    system ("pause");
    return 1;
}
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I believe that "biological computer" refers to DNA Computing. I heard about this years ago in the midst of the whole "quantum computing" hype, I don't know how much has been done about it now. The basic idea is to use DNA (or RNA) as storage instead of typical NAND gates in semi-conductors, and use biological processes akin to natural DNA/RNA replication mechanisms instead of transistor-based logic modules in typical CPUs. I don't know if there is anything really special about the potential of this technology, but it certainly an interesting concept.

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

The first thing you should try is to use a memory-mapped file. Depending on what is in your file, you might have to copy it first. So, you create a memory-mapped file, and "load" the content of your big file into that "memory", which, in actually, will have the effect of copying the file into a memory-mapped file. Then, you can use that memory as if it was RAM memory (although much slower, of course). At this point, you can just use the standard std::sort() function. It is a modified quick-sort-like algorithm, so, the main operation is the partitioning around a pivot element. Partitioning is usually done by starting at both ends of the array (or list) and swapping elements which are on the wrong side, until both traversal pointers (iterators) meet in the middle. So, these are sequential memory access patterns that are very suitable for pre-fetching mechanisms, so you can expect fairly good caching performance and a limited amount of RAM memory being used. Whatever you do, it is most likely that using a memory mapped file is going to be the best of all options, performance-wise.

If you can't or don't want to use a memory mapped file, then you can emulate it using your own iterator implementation (some kind of random-access file iterator). But, it will be quite difficult to create an efficient implementation for that, especially one that has good pre-fetching behavior.

The above two options are those you have that allow you to reuse …

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

Ok, to start let's presume the next scenario.
You need to make an application in Java or .NET that can handle operations with an address book. Operations can be: adding a new contact, deleting or updating an exinsting one. Search for a contanct by it's name. Sort after name, adress or phone number of a contanct. Export and import to, respectively from a XML file. Basic operations with entities actually.
Which of the two would make best for design time, implementation time and running time?

For such a simple application, it will most likely make no difference at all which one you use. Design time: exactly the same. Implementation time: depends only on your aptitudes at either language. Running time: my hunch would be to say that Java would run faster, but I can't tell for sure.

The difference will start to be felt on larger projects, especially those that require a lot of interoperation of various libraries, and which are available in which platform and how much work is needed to interface them.

The other difference will be in terms of development environments (IDE). Having a good GUI tool and a helpful debugger are important factors in these applications. So, then, you have to compare the development environments more than the actual platforms / languages.

Another question. When you find yourself in this scenario, which language will you go for and why?

If the project involves existing code to be fixed or extended …

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

The 3D case is no different than the 2D case, you just have a lot more cases to worry about. What have you tried?

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

find_urls should be a function with this signature:

string find_urls(const string&);

If it doesn't you'll get an error. I say this because your description of what the function find_urls does is completely at odds with its use as the functor in a std::transform call. Please provide a more complete description (and code) for that function.

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

I assume there is also an untold gentlemen's agreement that you don't vote for your own snippet if you have one in there.

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

They are basically competing products. When I talk from a language-theoretic point of view, they are very difficult to distinguish at all. The same goes for application domains, generally speaking, they target similar domains, in a very similar way. So, just as a general opinion, I would say that Java is more consistent (less of a Frankenstein framework like .NET), has a more established user-base, and is more portable. But I don't know enough of either to be able to draw specific contextual differences between them, I think they only differ in some details and for some specific tasks.

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

@waqasaslammmeo: Sure, buddhism is also a bad example, it's kind of hard to find a religion that doesn't contain a lot of violence, buddhism just comes to mind, but it is not really a peaceful religion either, but I repeat what I said about that subject: "that's besides the point." I was trying to make the point that this is not a battle between religions. I don't care what other religions say or how Islam compares to them, that's completely irrelevant. If you want to claim that Islam is true, "logical" and non-violent, then that claim must be supported on its own. What I mean is that trying to establish that Islam is more true, more logical and less violent than other major religions (which I think are all completely baseless and primitive anyways) is a pointless exercise because it doesn't get you any closer to the truth (and also because these kinds of comparative discussions are so heavily biased by the participants, which are both evaluating things with large openings for interpretation). Your burden is the following:

To establish that Islam is true:

  • Show that all statements in the Qur'an are clearly true, without room for interpretation.
  • Show contemporary, non-quranic evidence of the events described in the Qur'an, such as the genesis accounts, the "old testament" stories, the life of Mohammed, his battles and so on.
  • Show that the Qur'an could not have been written by anyone but Allah (through Mohammed). This is going to be a really hard …
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Step 1: Look at operator precedence and associativity rules in C++.
Step 2: Add parenthese in the expressions to mark the precedence more clearly.
Step 3: Determine which expressions are valid and which are not.

Hint 1: The thing at the left of an assignment = must always be a named variable.
Hint 2: The bool type, what logic operations output, is a simple integer type with 0 (false) or 1 (true) as value.

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

If you leave the SSHD plugged into the same slot as your original HDD was plugged into, then you probably won't have to change anything. When you get the other SATA wire, you just plug your HDD into the second slot. If there is any trouble, just go into the BIOS menu and edit the boot order to make the SSHD have priority over the HDD. As far as I know, there shouldn't be any problems.

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

First, try to just hold down the F8 key as you boot (before the windows bootloader), and that should get you into the windows bootloader, and you should at least be able to boot windows in safe mode and then do the change to make the timeout higher than 0!

Your grub menu should have an entry for Windows (it's added by default). If not, then add it with these instructions and you should be able to select it in the grub menu (usually one of the last entries in the menu).

If this fails for some reason, use a windows recovery disk and use bcdedit command line commands to change the timeout. You could also do a "repair" of the mbr to put the original windows bootloader, then you'll just have to redo the EasyBCD part (and don't set the timeout to 0 seconds this time).

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

There is a wiki-site maintained by a Daniweb member (daviddoria) and to which I contributed a few examples. It sounds like exactly what you are looking for: http://programmingexamples.net/wiki/Main_Page (it also includes examples in other languages, but the main one is C++, and you can also check out the Boost library examples).

Also, the "official" reference sites also have examples attached to most documentations on each library components. The "official" reference sites are:
http://www.cplusplus.com
http://en.cppreference.com/w/

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

electric --> car

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

How can you be thorn between ASP and C++? Two completely different languages with completely different application areas. What appears clearest to me is that you don't seem to have a good about what you want and what area you want to get into. Once you determine that, your choices will be a lot easier to make. You seem concerned about your expenses (of money and time), it will help releave your worries if actually are confident about the direction you are taking, confident that you like it and that you will do well in that area.

Here's my opinion on those courses:
Cobol: Forget it. It's an old legacy language that you'll only encounter if you have to maintain some ancient code running some factory or something.

XML: I took a course very similar to this one during my masters, for me, it was a waste of time. A lot of time just studying the way a particular file format is made, of course, XML is the most important file format of all, and is certainly complex with all extensions, but I'm not sure it is totally worth a "course" on it.

Networking: I also took a very similar course during my masters, and that one was pretty interesting. I think it is important to get a good knowledge of "how the internet works".

The other three, ASP, C++, and Java, are really all about what application area you prefer.

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

I guess the idea of your code is to sort the row elements and then pick the middle one as the median. However, your code is full of mistakes. The strategy is not optimal, but it should work, start by fixing all the little mistakes in the code, and it should work.

For a better solution, you should look into "selection algorithms".

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

You have to use an external library for this purpose. The "built-in" functions of C++ are limited by design (to make it portable to any system easily).

A good library for image manipulation is OpenCV (which is only Mac / Linux, as far as I know, EDIT: apparently they have Windows support now, this must be pretty new). Other options include FreeImage which is more minimal (load / save various image formats, and that's pretty much it). Also, most GUI libraries (Win32, MFC, Qt, WxWidget, GTK, etc.) include a number of basic image loading / saving capabilities, and some "canvas" system to draw and modify images.

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

So, if someone raped and murdered your wife, you would do nothing?

I can't imagine. Probably every inch of me would want to kill the guy, and if I had the chance I probably would (at least, in the heat of the moment). But that said, I would probably go to jail for that, and that's OK, that's how it should be. Such retaliation is understandable from a human / emotional point of view, but still, it is not an acceptable behavior, because a civil society cannot be built on the principle that when you were wronged (victimized) anything goes. A friend of mine from Mali told me about how in his country when the police catches a criminal, they bring him/her to the victim(s) of the crime (without a trial, of course), and allow them to do whatever they feel is just punishment. I don't think that's the way you want a civil society to function.

What do you think the US should have done about 9/11?

Getting a bit off-topic here. I'd say the US should have accepted the offer of the Taliban leaders to deliver Ben Laden and all afghani Al Qaeda members to the US on a silver platter, and then, put them up on trial. That is what should have happened instead of the horrors of the past decade. But that would have required Bush to understand that the Taliban and Al Qaeda are completely separate (and largely antagonist) organizations, and …

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

jim in quran this act is called jihad ,Allah said in quran “Fight in the cause of God those who fight you, but do not transgress limits; for God loves not transgressors.” [Qur’an 2:190]. so if someone attacks you . its your basic right to fight with them.

The Qur'anic description is not that of self-defence, it is a description of retaliation, which is very different. When Jim mentioned "self-defense" as one of a few exceptions in which killing a person is acceptable (and I agree with that), I'm pretty sure he wasn't talking about retaliation, as in, someone offends you or does you wrong and you then set out to kill that person or group. This is retaliation and vigilanty justice, and I would never consider that acceptable. This verse of the Qur'an is in complete contradiction with every code of law ever written since the code of Hammurabi in 2050 BC.

in quran Allah said ,"if anyone killed single innocent human ,it means he killed whole humanity" .

That's just a poetic verse with no practical use. The absolutism of considering every murder as being the same extreme act is a very crude and ineffective basis for a code of law, and most decent codes of law make various distinctions between premeditated murder, accidental homicides (like punching someone, which then bangs his head on the floor and dies), passion crimes, psychotic episodes, murders our of needs (money, food, adiction), and so on.

Second, what …

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

-1 prototype breadboard
-few sensors, you can get these online or from your local electronics store, in the UK we have a place called maplins that usually is good enough.
-two motors, one for forward, one for turning
-If you have lego technic raid your box for motors and gears and wheels

Let me expand a bit. Assuming you want to make a wheeled robot to go around like the rumba robot (robot vaccuum cleaner), by bumping into walls and turning in a random direction. The basic hardware would be:

  • Prototyping: A solderless breadboard, with a kit of jumper wires for it.

    • Later, get a proto-board (also called "stripboard"), for the "permanent" circuits.
    • You also should get a starter kit of resistors and capacitors.
  • Soldering kit (basically what you find in this kit):

    • Soldering iron, get two tips: a fat one and a thin one.
    • Solder: a roll of thin solder wires, and a roll of fatter solder wires is also nice.
    • A "helping hands" thing (stand with little clamps, very useful to hold things together).
    • Some wires and some wire cutters and clamps.
  • A few useful proximity / touch sensors:

    • 2-3 IR proximity sensors (about 10$-15$ each).
    • 2-3 light-touch switches (for a physical bumper).
  • Schmitt-trigger integrated circuits for all "digital" sensors (touch switches and if IR sensors are used as ON/OFF instead of analog distance read-outs).
  • Two motors: differentially-driven (i.e., two wheels …
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I'm not sure, but typically the "mnt" folder on most linux distributions is only for mounting temporary devices (like USB sticks). I wouldn't be surprised if there was some kind of automatic cleanup of that folder when starting up or shutting down the computer. That might be why it disappears. Is it part of the instructions to reboot after having done that step? And is it necessary that this folder be put at that location? Maybe some place other than the "mnt" folder would be a better idea.

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

Scandinavian Music Group - Näin minä vihellän matkallani

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

A simple robot like this (two wheels, differential steering, with some proximity sensors and possibly something else like a camera) is usually controlled with a microcontroller. Microcontrollers range from very simple to a smart-phone level of capabilities.

For very simple microcontrollers (uCs), they can be bought for as little as 20-30 dollars, but you'll need some electronics skills to integrate them into a robot (they are usually DIP-mounted, and require quite a bit of external circuitry like voltage regulators, pull-up/down resistors, and so on). If that is not something you are prepared or interested in doing, you'll have to go a step higher (in cost and capabilities). These simple uCs are typically programmed in C, and are rarely able to accomodate an operating system (or only a very simple OS, like FreeRTOS). Sometimes they allow C++ programming, but often with only limited capabilities (limited language support and reduced C++ standard library (or none at all)).

Then, you have mid-range uCs, like Arduino series. These are basically the same as the very simple uCs (Atmel AVR family), but they have more of the outside layer of electronics to allow for standard input-output protocol capabilities such as UART, TTL, PWM (and RC PWM), I2C, analog IOs, and maybe even encoder quadrature chips. And, with those you don't need to do much electronics besides soldering connectors, and mounting the chip with screws. As for programming, it's the same deal as for bare uCs, …

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

It should have come with your compiler. What compiler are you using? If your compiler doesn't find it, maybe the include-paths are not set correctly. Have you done a file-search for "windows.h"?

With MinGW, you can download and extract the win32 API headers and libraries from this page. But, normally, this is included in the installation.

You cannot just download windows.h, because that header is just the tip of the iceberg. It's basically a header that includes just about every possible function of the Win32 API, through many underlying headers (which is, of course, an absolutely terrible way to do things, but, hey, that's Microsoft for you). Using it also requires linking to a long list of libraries (usually setup by default on your compiler configurations, when installed, or when creating a new "windows" project).

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

A little taste of the genius of George Carlin (RIP):

"I never understood national pride. You should be proud of things you achieved or acquired on your own, not for an accident of birth."

"It's called the American dream, because you have to be asleep to believe it."

"Military cemeteries around the world are packed with brainwashed dead soldiers who were convinced God was on their side... We pray for God to destroy our enemies, our enemies pray for God to destroy us... somebody's gonna be disappointed, somebody's wasting their f'ing time, could it be... everyone!"

"The best thing you can do to a kid is warn him about all the bu115hit that's to come, and teach him how to detect it."

"I have as much authority as the Pope, I just don't have as many people who believe it."

"I'm completely in favor of the separation of Church and State. My idea is that these two institutions screw us up enough on their own, so both of them together is certain death."

"Inside every cynical person, there is a disappointed idealist."

"The main reason Santa is so jolly is because he knows where all the naughty girls live."

"Weather forecast for tonight: dark."

"If a man is standing in the middle of the forest speaking and there is no woman around to hear him...is he still wrong?"

"Why do they lock gas station bathrooms? Are they afraid someone will clean them?"

"Give a man a fish and he will …

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

Well, the recently active members page does show the geographical locations, but I think it not being updated properly, I still show up as being in Finland, which is where I lived when I first registered a couple of years back. I've been in Montreal ever since.

I guess it would be nice to compile such a picture, such as a world map with color-coded "members per country". Since the locations are stored in Daniweb's data-base it shouldn't be too hard to pull all that info and generate the map (or at least a table of country versus member count).

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

The main tool for being able to reuse the same piece of code in different contexts is the ability to treat an object as an abstract entity (with some predefined set of functionality), which is what polymorphism means. This really boils down to being flexible about the types of the object. It is true that inheritance from abstract interfaces is one way to achieve this, but there are some problems with this mechanism. There is always a trade-off between type-flexibility and run-time overhead (and amount of code needed).

If you want an object to be polymorphic, you have to deal with it in OOP terms, with an abstract interface with virtual functions, and by creating the object dynamically (referring to it via base-class pointers). This incurs overhead in the form of indirect memory allocations (causing problems of locality of reference), in the form of dynamic dispatching (e.g., calling virtual functions, which causes difficulties for pre-fetching, which is a very important factor for performance), and in the form of limited static analysis (that's when the compiler analyses the code and figures out ways to simplify it, or optimize it). Also, the more types of objects you have to deal with, the more interfaces you have to construct, increasing the amount of code. Furthermore, even with multiply inheritance and virtual inheritance, it is often difficult to get flexible class hierarchies (one class implementing many interfaces, or collaborating with other classes). And sometimes, when mixing two libraries each with their own class hierarchies …

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

Thanks for your input Rouf!

Although I do think that Jim's questions merit a more direct response, I also enjoy flailing ideas around, so let me jungle with yours a bit:

If I understand correctly, you use "energy" as an analogy for how God permeates everything and can do anything (kind of like "The Force" in Star Wars). It's a poetic view of energy, I'll give you that, but the main problem I would have with this is "intelligence", as in, how can this "energy" or universal force develop a will of its own and constitute a sentient being? Without "intelligence" within this universal force, it isn't much of a God, so that becomes a pretty critical point. I'm not excluding the possibility that there is some sort of intelligence binding everything, and if there is a mechanism by which this is possible, I'll be all ears if you can demonstrate that mechanism.

How does one detect intelligence? One answer is: the presence of choices, because that is the exercise of intelligence. Of course, this implies the ability or freedom to make choices (acts motivated by some thought process), without that ability, the "intelligence" is just a passive observer with no detectable signs of intelligence (e.g., a person who is completely parallized and cannot communicate in any way, but still has a working brain, he is "intelligent", but that intelligence cannot be detected or be useful). So, following that train of thought, the million dollar question is: Is there room …

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

You are assuming that all of us have the mental capacity of great thought processes.

We are only assuming that when somebody claims knowledge of something, he is also willing and able to think / discuss that claim / subject. If you are not able or willing to reflect upon a subject, you should simply abstain, and there's nothing wrong with that, but it implies not taking any position with conviction. There are many things for which I hold no particular position or only weak inclinations towards one side, these are not subjects I discuss or think about, I leave those subjects to others. What you cannot do is hold a position with strong conviction without being able or willing to defend it, hopefully, with a candide and rational discussion.

Most people are like sheep who blindly follow a leader.

Then bring me the leader, I'll challenge him. But seriously, one of my main reasons for engaging in these types of discussions is to get people not to behave like "sheep". I just have higher hopes for humanity than this pathetic image of "the herd".

Belief in a God is really a gamble, and we won't find out whether or not its true until we die. If there is no God and no afterlife, then no harm done. But ... the alternative is pretty awful for someone who believed there is no God.

This is called Pascal's Wager. There are many problems …

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

These are some pretty potent questions, however, I wouldn't expect a "good muslim" to answer anything but yes, yes, and yes (well, the last answer might not be "yes"). I would be more interested in the underlying assumptions and implications of the questions:

  • Do you believe the Qur'an is the word of Allah as handed down to Mohammed?

    • What are the characteristics of this being you call Allah? Omnipotent? Omniscient? Benevolent? Eternal? Time-less? In what realm does He reside? How does He interact with this world?
    • How did Allah communicate his words to Mohammed?
    • What are the reasons for excluding the possibility that Mohammed made up the "words of God"?
    • Who was Mohammed? What do the contemporary non-quranic records of his existence tell? If any exist.
  • Do you believe that the Qur'an is infallible?

    • Or is Allah infallible? Or both?
    • If passages of the Qur'an were found that contradict other passages of the Qur'an, how do you determine which is true? And how do you resolve the apparent non-infallibility?
    • If passages of the Qur'an were found that contradict well-established modern scientific facts or theories, which one will you believe?
  • Do you believe that Islam, as laid out in the Qur'an preaches a creed of non-violence?

    • If yes, how should the violence in the Qur'an be considered? As teaching lessons (about what not to do)? As justified under certain circumstances? Which circumstances?
    • If yes, is there any difference between the attitude to have visa-vi muslims, non-muslims …
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

It appears that the 3.0 and up headers are still in development. There is a draft for gl3.h.

And MinGW should be able to link directly to OpenGL32.dll, if not, then follow these instructions to create the import library.

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

You can know what is supported using the glGetString function. This will allow you to get the version number and the list of supported extensions.

Overall, you should try to either stick to the core functionalities supported by the version you have, and possibly use supported ARB extensions. Basically, extensions move from vendor-specific (like NV), to general extension (EXT), to extensions accepted by the architecture review board (ARB), and then they become core functionalities on newer versions. Today, I think most hardware supports at least version 2.5 or 3.0 or later. Make sure that the header files that you are using to access the functions are up-to-date, and there shouldn't be much of an issue.

Normally, versions always remain backward compatible too.

As for actual game engines, they first isolate (behind abstractions) all the rendering code, so that they can easily swap out different rendering engines (OpenGL, Direct3D, and different versions of their renderers). Then, they decide what minimum capabilities they want their renderer to have, and that determines the minimum version of OpenGL or Direct3D that is needed to make that work (this would be the "minimum required DirectX or OpenGL version" that appears on the box). Finally, they code alternative rendering codes depending on what level of feature support the hardware provides (and according to those "graphics settings" that the player configures). So, yes, it is basically hard-coded, but you structure your rendering code such that you don't have too much repetition. For example, you have …

triumphost commented: Edit: Never mind. Thanx for all the help. I updated my extension includes. It's enough to work :) EXCELLENT Helper +0
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Have you looked into Vertex Buffer Objects (VBOs).

The glVertexPointer mechanism is older, before the time where it would be possible to transfer the vertices to the graphics card (in those days, you could barely store all the needed textures on the graphics card memory).

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

Ok, well, count that as a slip of the tongue, I meant "we" in an impersonal sense (one of the side-effects of being a native French speaker, where "we" and "one" are the same pronoun).

Ridiculing people's religious beliefs is not something I tend to do much either, I have other things to do or talk about. But I don't consider it off-limits though. For me, it's a matter of honesty, I find the belief that Elvis is still alive just a ridiculous as to believe a man can survive 3 days in the belly of a giant fish, ridiculing one while "respecting" the other just seems dishonest to me.

If someone comes up to you and says he worships Zeus and believes Hercules was His son, the one true savior of the world, you would probably have trouble containing your laughter. Why is it different when people say they worship Allah the one true god and believe that Mohammad is His prophet? The body of evidence is the same for both, only the number of people who believe it is different, which I don't care about.

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

The easiest thing in this case is to just use a smart pointer, as so:

#include <ostream>
#include <fstream>
#include <iostream>
#include <memory>
using namespace std;

// a custom deleter that does nothing (no sure why the standard library doesn't have one of these):
struct null_deleter {
  template <typename T>
  void operator()(T*) const noexcept { };
};


shared_ptr<ostream> set_output_stream(int argc, char* argv[])
{
    // if there are any arguments, assume the first argument is the output
    // filename and try to open it.

    if(argc > 1)
    {
        return shared_ptr<ostream>(new ofstream(argv[1]));
    }
    else
    {
        // no arguments, so use cout (with no deleter)
        return shared_ptr<ostream>(&cout, null_deleter());
    }
}


void HelloWorld(ostream& outs)
{
    outs << "Hello World\n";
}


int main(int argc, char* argv[])
{
    shared_ptr<ostream> outs = set_output_stream(argc, argv);
    HelloWorld(*outs);
    return 0;
}

If you don't have a C++11 capable compiler, just use a boost::shared_ptr instead (or std::tr1::shared_ptr).

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

Do you have to use VC++? That's the main question.

Because if you can use MinGW/GCC, then there is no problem at all because it includes a make.exe program that you can use to build your project. Of course, you'll still have to worry about all the external dependencies, making sure their include/lib paths are correctly setup for Windows (because, obviously, it is completely different from Linux). And most MinGW-oriented development environments (like DevC++, CodeBlocks, Eclipse, etc.) allow you to easily load up a makefile-based project.

However, if you have to use VC++ (version newer than VC6), then you have basically no choice but to create a new project for scratch and add all the files. Visual Studio does have some facilities to create a project from existing code, but it is still largely a manual setup from scratch. Visual C++ used to have support for makefiles, but they dropped the feature (I'm pretty sure they did so on purpose). Basically, Microsoft doesn't want any inter-operability between their products and anything else in the world, that's just one example, and a prime reason why I never end up using Visual Studio because their build system is crap and it does play nice with anything else.

Finally, are you sure the code uses makefiles? Makefiles are often the intermediate output of another build-system (because you have to be a bit masochistic to create makefiles manually for a non-trivial project). Often, you'll have a build-system like cmake, auto-conf, bjam, qmake, and others …

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

You cannot do what you are trying to do because objects in C++ are not references, they are objects. When you create the outs object in main(), you create an object, not a reference to another object, so you cannot "re-seat" it by making it refer to something else (in particular, std::cout). One simple way to achieve what you are trying to achieve is to do the following:

#include <ostream>
#include <fstream>
#include <iostream>

std::ostream& global_out(std::ostream& outs = std::cout)
{
    static std::ostream& gbl_out = outs;
    return gbl_out;
}

// if you want to assign all outputs to std::cerr, you do:
int main()
{
    global_out(std::cerr);

    global_out() << "Hello World\n";

    return 0;
}

// if you want to assign all outputs to std::cout, you do nothing:
int main() 
{
    global_out() << "Hello World\n";

    return 0;
}

// if you want to assign all outputs to a file, you do:
int main() 
{
    std::ofstream file_out("my_program.log");
    global_out(file_out);

    global_out() << "Hello World\n";

    return 0;
};

That's one simple way to do things, it is not super-robust, of course, you should implement the global-out as a proper singleton implementation, but you get the idea. And, technically, outputs that would occur after main has finished would be unsafe, but that's always the case anyways.

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

no muslim make any cartoons of jesus , but non-muslims make cartoons of our prophets , why there is no rules for them , why international media not taking any steps against them ,in israel if someone say , hitler is good man then there is death for him ,

You are perfectly welcome to do cartoons of jesus. Many atheists do just that, because it's fun to ridicule religious beliefs. The rule is the same for everyone and every subject, you are allowed to say whatever you want (as long as it is not a death-treat or a direct and explicit invitation to violent actions) in whatever form of media available to you (speech, drawing, editorials, blog posts, etc.). That's it. If people say things you disagree with, then you can express that disagreement with your own rights of free speech, or you can simply ignore them. There are no "illegal" subjects of discourse, you can speak about whatever you want and say whatever you want. Of course, there are "taboo" subjects, but these are not illegal, simply not discussed a lot because it is offending to many, but if they are spoken about, nobody gets arrested for it, let alone killed for it.

If, in Israel, someone says that Hilter was a good man, that person should suffer no legal consequences or any kind of physical harm as a consequence of that. He would not get murderered, and if he did get murdered by someone who …

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

As for the video, I'm sorry that I can't watch it at the moment. I am at the cottage where bandwidth is limited. It will have to wait until September.

Don't bother. It's the Zakir Naik speech, hard to miss if you looked into the issue at all. His speech is pretty much worthless, just a confirmation-bias bath for its audience. He first pisses on atheists a bit, then he starts out with the classic watchmaker argument, which is easily debunked. Then the rest is mostly about stating vague Qur'an verses and conflating them to match modern science:

  • "The heavens and the earth were of one piece, then We parted them." (21:30): Supposedly this tells of the Big Bang. I'm sorry but my mind does not stretch that far. By the way, this is exactly the same as the old-testament account of genesis, which is equally stupid, and predates the Qur'an.
  • "The moon has reflected light.": Wow, shocking! (sarcasm) It surely must have been revealed from God, because no-one can figure out that the thing in the sky that is always really bright and full produces its own light (the Sun), and that the thing in the sky that is not very bright at all and goes on a cycle from full to new is reflecting light (the Moon). Aristotle figured this one out, on his own, about a thousand years before the Qur'an, and btw, while he was at it, he also proved …
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Whenever you see code being repeated over and over, a light should come up saying: "I could probably use a loop for this!". For starter, you could easily condense your function into a single set of nested for-loops, as so:

void testFunc00(uchar * in, int len, uchar ** out) {
    int i = 0;
    for(int j = 0; j < 4; ++j) {
      for(int n = 0; (i < len) && (in[i] != '\0'); ++i, ++n)
        out[j][n] = in[i];
      ++i;
    }
}

You could probably add the maximum number of splits as a parameter too:

void testFunc00(uchar * in, int len, uchar ** out, int max_splits) {
    int i = 0;
    for(int j = 0; (i < len) && (j < max_splits); ++j) {
      for(int n = 0; (i < len) && (in[i] != '\0'); ++i, ++n)
        out[j][n] = in[i];
      ++i;
    }
}