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

I hope you guys realize you might be putting yourself in danger of being accused of plagarism. Just saying.

BTW, to solve the minimum-spanning-tree (which is actually just the same as the Dijkstra algorithm) you can do:

boost::prim_minimum_spanning_tree(
   g, goal_v, 
   get(&VertexProperty::predecessor, g),
   get(&VertexProperty::distance, g),
   get(&EdgeProperty::weight, g),
   boost::identity_property_map(),
   do_nothing_dijkstra_visitor());

which also sets the predecessors to make up the minimum-spanning-tree.

As for the traveling salesman problem, you can create a vector to hold the tour, and call the BGL function for an approximate TSP solution, as follows:

std::vector<Vertex> tsp_tour;

boost::metric_tsp_approx_tour_from_vertex(
  g, start_v,
  get(&EdgeProperty::weight, g), 
  back_inserter(tsp_tour));

And then, the vector tsp_tour will contain the list of vertices visited by a TSP tour.

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

No, you need to do this:

while (std::getline(fin,tempString)){ // (Location1, Location2, 6)
        //remove parentheses
        tempString.erase( tempString.begin(), tempString.begin() + tempString.find('(') + 1 );
        tempString.erase( tempString.begin() + tempString.find(')'), tempString.end() );

        std::cout<<std::endl<<tempString;

        std::stringstream temp_ss(tempString);
        std::getline(temp_ss, tempName1, ',');
        { 
          std::size_t first_c = tempName1.find_first_not_of(' ');
          std::size_t last_c = tempName1.find_last_not_of(' ');
          tempName1 = tempName1.substr(first_c, last_c - first_c + 1);
        };

        std::getline(temp_ss, tempName2, ',');
        { 
          std::size_t first_c = tempName2.find_first_not_of(' ');
          std::size_t last_c = tempName2.find_last_not_of(' ');
          tempName2 = tempName2.substr(first_c, last_c - first_c + 1);
        };

        temp_ss >> weight;
        // Add edge to graph, by finding vertices associated 
        //  to tempName1 and tempName2:
        add_edge(name2v[tempName1],name2v[tempName2],EdgeProperty(weight), g);
    }
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

only another hour, I gotta say I didn't think this project would be that hard when he gave us the write up (in theory this should have only taken an hour), but the sytax is so daunting I'm not sure how we were expected to have time to do all three tiers of this project.

I think your prof assumed that the students are familiar with C++ already. A person who is already familiar with C++ syntax and has an average level of competence with the language can solve this assignment within a couple of hours, easily. I don't know if it was stated anywhere in the course pre-requisites that good C++ knowledge was necessary for the course, but if it was, then this is certainly a reasonable assignment. It is not reasonable if there was no pre-requisite of the sort. If you ignored that pre-requisite, thinking that you could just learn C++ as you go, then you are currently experiencing the consequences of that poor judgement call.

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

The find function finds the index of the first character specified. Just read the docs for string. If there are no characters equal to that one, it will return the index at the end of the string.

Actually, the easiest way to just remove all the spaces is this:

tempName1.erase(std::remove(tempName1.begin(), tempName1.end(), ' '), tempName1.end());

But that will also remove spaces in the middle of the name.

To extract only the string in the middle (between leading and trailing spaces), you can use this:

std::size_t first_c = tempName1.find_first_not_of(' ');
std::size_t last_c = tempName1.find_last_not_of(' ');
tempName1 = tempName1.substr(first_c, last_c - first_c + 1);

which looks for the first non-space character and the last non-space character, and then extract the sub-string between those two indices (the + 1 is to get the length between the indices to include the last non-space character).

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

Yes that's right.

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

yeah mike is awesome, he is the only reason I've not failed this class already.

I sympathize with you guys. I think your prof really threw you in the deep end with this assignment. If you were to do this without BGL, you would have to implement an adjacency-list data structure and a Dijkstra algorithm, both of which can be a big challenge for any programmer, let alone beginners. If you use the BGL, you don't have to implement all that, but you have to use a library that is definitely not meant for beginners to use (i.e., although, as an expert, I love the BGL for its flexibility, it is often criticised for being too difficult to use). It is a bit unreasonable for a prof to expect you to pick-up on being able to use the BGL just like that, he should have given you at least a whole lecture (e.g., 3 hours) on how the BGL works and how to use it.

This is why I'm helping you far more than I usually would.

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

The program that I have posted last works correctly on my end. I tried using the following file:

Vertices:
Location1,Location2,Location3,Location4,Location5
Edges:
(Location1,Location2,5)
(Location2,Location3,1)
(Location2,Location4,2)
(Location3,Location5,3)
(Location1,Location4,1)

And I ran the program (exactly as posted a few posts back), and I got the following output:

$ ./dijkstra_solver 
please enter the data file name: dijkstra_solver.txt
file loaded.


How would you like to process your data file?
1.) shortest path
2.) minimum spanning tree
3.) Travelling Salesman

please enter 1,2,3 or Q to quit: 1

please enter the location name to start from:Location1

please enter the location name for the destination:Location5
distances and parents:
Location1 Location4 Location2 Location3 Location5

And you can verify yourself from the weights of the edges that this is indeed the shortest path from 1 to 5.

I think the problem might be related to having spaces between the names in the file. So, you might want to add some code to remove the leading or trailing space characters from the names you get from the file. You can do this the same way as with the removal of the parentheses.

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

I think that you are entering the wrong names, or something like that. If the names are not in name2v, the output will be 0, which is Location1, and if both are not found, then both the start and goal will be 0.

You should check again that the names are correct.

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

As I gave you the method to walk along the solution path on the other thread, here is the complete code (also removed some unnecessary junk, it is generally not a good idea to put together random pieces of code, you have to understand what you are doing):

#include <iostream>
#include <fstream>
#include <map>
#include <vector>
#include <string>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/visitors.hpp>
#include <boost/graph/breadth_first_search.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/metis.hpp>

typedef boost::adjacency_list_traits<
    boost::vecS, boost::vecS, boost::undirectedS, boost::listS> GraphTraits;
// type 'Vertex' identifies each vertex uniquely:
typedef GraphTraits::vertex_descriptor Vertex;

// Property type associated to each vertex:
struct VertexProperty {
    std::string name;  // Name of vertex (i.e., "location")
    Vertex predecessor; // Predecessor along optimal path.
    double distance; // Distance to the goal, along shortest path.
    boost::default_color_type color; // for use by dijkstra.

    VertexProperty(const std::string& aName = "") : name(aName) { };
};

// Property type associated to each edge:
struct EdgeProperty {
    double weight; // distance to travel along this edge.

    EdgeProperty(double aWeight = 0.0) : weight(aWeight) { };
};

// Type of the graph used:
typedef boost::adjacency_list<
  boost::vecS, // out-edges stored in vector 
  boost::vecS, // vertices stored in vector
  boost::undirectedS, // undirected graph (edge don't have a specific direction)
  VertexProperty, // properties associated to each vertex.
  EdgeProperty // properties associated to each edge.
  > Graph;
// Create a global graph object 'g'
Graph g;

// This is a visitor for the dijkstra algorithm. This visitor does nothing special.
struct do_nothing_dijkstra_visitor {
    template <typename Vertex, typename Graph>
    void initialize_vertex(Vertex u, const Graph& g) const …
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

After having called dijkstra the function, you should be able to just walk through the graph via the predecessor records. Something like this:

std::string start_name;
std::cout << "Enter start location: ";
std::cin >> start_name;
std::cout << "The shortest path is:" << std::endl;
Vertex cur_v = name2v[start_name];
while( cur_v != name2v[tempName1] ) {
  std::cout << g[cur_v].name << std::endl;
  cur_v = g[cur_v].predecessor;
};
std::cout << g[cur_v].name << std::endl;

That should print the sequence of location names between the given start-point and the goal point (which is the one passed to the dijkstra function, i.e., name2v[tempName1]).

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

Alright, I feel generous today. Here's the code for the part that constructs the graph:

std::map<std::string, Vertex> name2v;

std::getline(fin, tempString); //Vertices:
std::getline(fin, tempString); //Location1, Location2, ...
std::stringstream tempSS(tempString);
while (std::getline(tempSS,tempName1, ',')){
    name2v[tempName1] = add_vertex(VertexProperty(tempName1), g);
}
std::getline(fin,tempString); //Edges:
while (std::getline(fin,tempString)){ // (Location1, Location2, 6)
    //remove parentheses
    tempString.erase( tempString.begin(), tempString.begin() + tempString.find('(') + 1 );
    tempString.erase( tempString.begin() + tempString.find(')'), tempString.end() );
    std::stringstream temp_ss(tempString);
    std::getline(temp_ss, tempName1, ',');
    std::getline(temp_ss, tempName2, ',');
    temp_ss >> weight;
    add_edge(name2v[tempName1], name2v[tempName2], EdgeProperty(weight), g);
}

That's it.

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

Knowing how the Dijkstra algorithm operates, I would assume that your "Compare" function relies on a "distance" values associated to the nodes, and that these distance values change during the iterations of the algorithm. As the distance values change, the priority-queue (which is just a "heap") becomes corrupt, or out of order (i.e., the "heap-property" no longer holds true). This is why the error occurs. You simply cannot change the distance value without updating the priority-queue to make sure that it remains valid. You need to use a kind of heap or priority-queue that can be updated on-the-fly. The standard priority-queue does not allow that. Find another one, or implement your own (personally, I use the boost::d_ary_heap_indirect class, but it's a little hard to use).

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

The problem with add_edge(tempName1, tempName2, weight, g); is that the strings tempName1 and tempName2 are not vertex descriptors and weight is not an edge-property. These two problems make it so that the compiler does not find a function like that one (that takes two strings and a double).

The edge-property part is easy to solve, just do EdgeProperty(weight) instead of just weight.

The other problem is a bit harder (as I tried to explain earlier). The problem here is that you cannot refer to vertices by their name, you need to refer to them by vertex-descriptors (i.e., the Vertex type in your code), which is what the BGL uses to identify vertices of a graph (these are actually indices or pointers to a vertex, but that's not important). When you do add_vertex, it returns a vertex-descriptor to the newly created vertex. You need to record all those vertex-descriptors and associate them with the correct name. For that, just use a std::map<std::string, Vertex>. Then, all you'll have to do to create the edges is to retrieve, through that map, the vertex-descriptors corresponding to the names tempName1 and tempName2.

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

Yey! That was a fast delivery! Thanks.

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

I'm wondering if it is possible at all to disable the CTRL-S action when writing stuff on the editor. This is just because I am a frenetic hitter of the CTRL-S key combination, which comes from years of just writing lots of stuff (code or text) and constantly hitting that combination to save the work. To me, this is an unconscious reflex that is hard to suppress (and I don't really want to, because it's a good unconscious reflex to have). But, it is annoying when writing posts here because it triggers the saving of the web-page (with a "save to.." pop-up). It would be nice if it was just disabled such that it does nothing while the focus is on the editor.

Thanks.

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

I don't recommend that you use the old-style boost::property properties for your vertices and edges. You should use bundled properties instead. To run the Dijkstra algorithm, you will need properties for "predecessor", "distance", "weight" (for edges), "index", and "color". So, you could use the following structs for the vertices and edges:

typedef boost::adjacency_list_traits<
  boost::vecS, boost::vecS, boost::undirectedS, boost::listS> GraphTraits;
typedef GraphTraits::vertex_descriptor Vertex;

struct VertexProperty {
  std::string name;
  Vertex predecessor;
  double distance;
  boost::default_color_type color;

  VertexProperty(const std::string& aName = "") : name(aName) { };
};

struct EdgeProperty {
  double weight;

  EdgeProperty(double aWeight = 0.0) : weight(aWeight) { };
};

As for the "index" map, you can use the identity-map because the vertex descriptors of a graph that uses vecS for VertexListS argument will be the same as the vertex index.

The last piece of the puzzle is the dijkstra visitor class. For a simple "do nothing" visitor, you can use this one:

struct do_nothing_dijkstra_visitor {
  template <typename Vertex, typename Graph>
  void initialize_vertex(Vertex u, const Graph& g) const { };
  template <typename Vertex, typename Graph>
  void examine_vertex(Vertex u, const Graph& g) const { };
  template <typename Edge, typename Graph>
  void examine_edge(Edge e, const Graph& g) const { };
  template <typename Vertex, typename Graph>
  void discover_vertex(Vertex u, const Graph& g) const { };
  template <typename Edge, typename Graph>
  void edge_relaxed(Edge e, const Graph& g) const { };
  template <typename Edge, typename Graph>
  void edge_not_relaxed(Edge e, const Graph& g) const { };
  template <typename Vertex, typename Graph>
  void finish_vertex(Vertex …
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

To input all the vertices, you should do it in two steps. First, you input the entire line into a string (using std::getline). Then, you put that string into a std::stringstream and you input each individual name using std::getline with the delimiter as ',' character. Like this:

std::string temp_str;
std::getline(std::cin, temp_str);
std::stringstream temp_ss(temp_str);
std::string temp_name;
while( std::getline(temp_ss, temp_name, ',') ) {
  std::cout << "Got name: " << temp_name << std::endl;
};

That should print every vertex name.

For the edges, you should do something similar to get the individual values (name1, name2, weight). You can eliminate the parentheses using the string's functions to find characters:

std::string temp_str;
std::getline(std::cin, temp_str);
// eliminate the parentheses:
temp_str.erase( temp_str.begin(), temp_str.begin() + temp_str.find('(') );
temp_str.erase( temp_str.begin() + temp_str.find(')'), temp_str.end() );
// then, put in string-stream:
std::stringstream temp_ss(temp_str);
std::string name1, name2;
double weight;
std::getline(temp_ss, name1, ',');
std::getline(temp_ss, name2, ',');
temp_ss >> weight;
// print results:
std::cout << "Got first name: " << name1 << std::endl;
std::cout << "Got second name: " << name2 << std::endl;
std::cout << "Got weight: " << weight << std::endl;

which should give you the names and weight of the edges.

Start by getting all that working, and then, worry about constructing the graph for calling the dijkstra algorithm in BGL.

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

What code do you have so far? We don't just do people's homeworks, you have to show that your are trying to solve the problem, and ask about specific problems that you are having with your code.

Hinata_Dev commented: the code I have is too long :/ +0
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Please use English in this forum.

(Du bist glücklich dass ich Deutsch verstehen kann)

All seems correct. However, because your KalmanFilter.cpp file is a C++ file, and most other source files (especially Car.c) are C files, it might just be a problem with name-mangling. Your C files expect a C function called "KalmanFilter", but your KalmanFilter.cpp file defines a C++ function of the same name, which will be mangled (to account for overloading) and will thus not be found by the linker.

Have you declared your KalmanFilter function as extern "C" in your header file (under a #ifdef __cplusplus condition)?

Also, if everything else is in C, you might as well make the KalmanFilter file into C files as well.

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

The typical way to solve the "reset" and "store path" problem for a shortest-path algorithm on a graph is that you do indeed store a "cost" in each node, but you also store a "predecessor" ID in each node. The "predecessor" acts as a back-tracing record of the optimal path. With the "from" and "to" nodes, once you computed the shortest path, you just start from the "to" node and back-track (from "predecessor" to "predecessor") until you are back at the "from" node, and that is your shortest-path trace. Also, another trick is to solve the problem backwards, from "to" to "from", and then, the back-trace from "from" to "to" is in the correct order already.

As for the "reset" function, it is merely a matter of going through all the nodes and edges and resetting all the algorithm-specific values (priority, colour, cost, and predecessor) to whatever is their default / invalid / blank value. The graph itself must be left untouched, i.e., preserve nodes and edges, and their properties.

Btw, if this is more than a homework, you might consider using an off-the-shelf library, such as the Boost Graph Library (BGL) which has several of these algorithms already implemented. That's what "professionals" use.

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

This would depend on the IDE you are using. It will usually be somewhere within the project's directory, i.e., near the cpp file, but not exactly in the same directory. Look for a directory named either "Release" or "Debug", or even "build".

Alternatively, just make a file search for the executable file.

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

Yes. We are a polite people. Rather than breaking out the guns we just said "we'd like to leave now, please."

A selective politeness, may I add. History is written by the victors. Your province's founder wouldn't exactly choose the word "polite" to describe Canadians. Nor would the Patriotes. Nor the Acadiens. Nor the disenfranchised first nations' people. Nor the conscripts of ww1 and ww2. I doubt René Lévesque would describe Pierre-Eliotte Trudeau as "polite".

But who am I do speak, I'm just a descendent of the nègres blancs d'Amérique. And, hey, it's not like you could write an entire book about Canada's dark and forgotten baggage... oh wait, there were three (at least) (unless you want to comfort yourself with the nauseating writings of the Mordecai Richler).

I agree that we, canadians, are a polite people, but it is a rather recent state of affairs. And things can quickly slip. They already are slipping.

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

The error in your code is that in lines 46 to 50, you redeclare a new set of variables (gross, state, federal...) which are local to the inside of the while loop. The while loop condition, however, is outside of that scope, meaning that it is referring to the variables declared prior to the loop (at lines 27-31). In C/C++, the rule is that invoking variables (like at lines 52-59) always refers to the variables with those names in the narrowest scope, meaning that those statements simply enter values into those inside-the-loop variables, and does not change the values of the outside-the-loop variables with the same names. And thus, those variables never change value, meaning that the condition never changes, and the loop never ends.

You should simply remove lines 46 to 50, and it should work as expected.

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

Your problem is a linking problem. To use openGL you must not just include the header files, but also link to the OpenGL libraries. If your installation managed to find the OpenGL headers (as it did, since it compiled correctly, just didn't link correctly), then it almost certainly means that the OpenGL libraries (that you need to link to) are also installed.

See this page. What you need to pay attention to is the line that says how to compile a program:

$ gcc -o hello.exe -Wall hello.c glee.lib glut32.lib -lopengl32 -lglu32

As you see, the *.lib and the -l* parts tell the compiler about the libraries that are needed to be linked with your program. If you are using an IDE, then you should look for a configuration option that allows you to enter the names of the additional libraries to link to. In there, you would need to add glee.lib, glut32.lib, libopengl32.a and libglu32.a. That should do the trick. Otherwise, just try to compile in command-line using a command similar to that above (replacing the source-file and executable names with your own).

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

Being half-Swedish, I can testify that Xmas has very little to do with Christianity. Sweden is both one of the most atheistic countries (if not the most) and one with the most Xmas traditions. Sweden is also one of the last places to convert to Christianity in Europe, and many "Christian" holydays are Christian only by name, as most traditions are still mostly pagan (e.g., inspired by the worship of stars, the sun, the spring feast on the remaining winter preserves, dancing around the first flowers blooming in summer, etc..).

Xmas is called "Jul" in Sweden, which is a old norse mythological name for roughly the month around the winter solstice. There is no Santa Claus (uhmm.. spoiler alert!), I mean, the stories told to children is about the "Tomte" (or gnomes... yes, the same as those garden gnomes.. small old men with pointy red hats) which live in the mountains, each having a particular village attributed to them, for which they make gifts and distribute them to their village by cross-country skiing (or riding a Julbock) door-to-door on the 24th of december. Some also have the Julbock distribute the gifts, which is even more pagan / old-norse mythology (the goat is Thor's magical goat).

Xmas time starts with the advent candles. More importantly, there's Sankt Lucia which many people see as more important than Xmas day. It usually involves getting all the girls (children) from the local area to dress up in white robes and …

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

Point taken, I guess you could say I don't judge difficulty like most.

But still, GUI programming in general (regardless of language) is mostly a matter of doing a lot of fairly trivial coding (coding event handlers, drag-and-drop designing the interface, and writing simple front-end code). So, in my perspective, GUI programming can either be extremely easy, up to just easy, and in C++, it's in between, at "very easy". But I also don't really have huge experience with GUIs, I never wrote GUIs larger than 30-40 kLOCs.

I first started doing GUIs about 15 years ago, with Delphi (with VCL (Visual Component Library)), which is well-known (in its day) for being one of the best GUI toolsets out there and for pioneering RAD (Rapid Application Development). To me, this was indeed a wonderfully easy language + GUI library combination, pretty much as easy as can be. Then, I moved to the C++ port of the VCL (in C++Builder), and it was nearly as easy to use as the native Delphi version. Now, I use Qt for most GUI things I do (which is not much in comparison to the "real coding" that I do). And, in my opinion, Qt in C++ is still very easy, certainly not nearly as good as the VCL, but the portability (across OS and across development environments) and the fact that it is still "alive" and actively developed make it the best choice.

take years to write/test/debug significant applications in pure c++ and …

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

Is It possible to work with GUI(Graphical User Interface) in C++?

Certainly. It's all pretty much dead on the "Microsoft" side of things (Win32 and MFC are pretty much deprecated now, and all alternatives are .NET, which isn't very C++-friendly). But that does not really matter (who would use Microsoft products in C++ anyways?). I would recommend Qt for all your GUI needs. It is very easy and portable, and overall pretty well designed (albeit a bit old-fashion). Other alternatives, like VCL or WxWidget, are, for the most part, not very attractive compared to Qt.

Or Is it not the ideal computer language for this?

Not exactly ideal. GUI programming is one of those areas where object-oriented programming is very appropriate (a lot of reliance on run-time mechanisms), and where a garbage collector does make life easier. Doing object-oriented programming in C++ is perfectly fine, although it is a quite small subset of the C++ language as a whole (so, to me, it feels like driving a sports car and only using the first gear). And I have not seen a GUI library in C++ that includes a garbage collector, and that could make some things easier.

Certainly, languages that are "pure" OOP and garbage-collected (C# / Java) are more ideal for GUI programming. Well, those languages were designed explicitely for that purpose, so it would look pretty terrible if they were not even good at that.

That said, doing GUIs in C++ is …

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

Jumping the cmos pin is not going to do anything to your hard-drive. This only resets the firmware and configuration of your bios to its original (factory) configuration. It will not affect the OS boot sequence, nor the OS installation itself. But I doubt that this would be a bios / firmware issue, especially if you did not do anything special with those. It sounds more like a hardware problem.

If your OS is Win-XP, consider changing it since the support for it will stop in a few months. If you don't have access to a newer Windows version (7-8) or the rig won't be able to handle it, consider installing a Linux distro instead, which is great way to give a second life to an old PC.

leds are still lit green, green orange, red

That seems like the most visible sign of a problem. LEDs don't change color for no reason, and I doubt the different colors are there for decorative purposes. You either have defective RAM sticks, or a defective motherboard.

The 2 system fans are wired a bit strange, they're pulling power (red/black leads) out of adapter blocks on one of the 4 pin power supply plugs, then a white lead is tapped into the fan's 3 pin connector and goes to the 3 pin terminal on the mobo.

I think this is a fairly common wiring, especially when an additional fan was introduced (e.g., to cool some overclocked components). However, it …

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

The problem is that almost anything can convert to char, including all your implicit conversion types int, long and double. Once you eliminate all those conversion operators, it works:

#include <iostream>
#include <string>

using namespace std;

class Variant
{
private:
    string result;
public:

    Variant()
    {
    }

    template<typename B>
    Variant(B val)
    {
        result=to_string(val);
    }

    Variant(string val)
    {
        result=val;
    }

    Variant(const char val)
    {
        result=val;
    }

    Variant(const char *val)
    {
        result=string(val);
    }

    Variant(bool val)
    {
        result=to_string(val);
        if (result=="0")
        {
            result="false";
        }
        else
        {
            result="true";
        }
    }

    friend ostream& operator<< (ostream &out, Variant &VResult)
    {
       out <<VResult.result;
       return out;
    }

    friend istream& operator >> (istream &in, Variant &VResult)
    {
        getline(in,VResult.result);
        return in;
    }

    operator const string&() const
    {
        return result;
    }

    operator string&() 
    {
        return result;
    }
};

int main()
{
    string b;
    Variant a;
    b="oi";
    a=b;
    a="oi";
    b=a;// OK
    cout << b;
    return 0;
}

This is why these types of variant classes (like boost::variant or boost::any) never have implicit conversion operators, they always rely on explicit conversions (or cast functions). This works:

#include <iostream>
#include <string>

using namespace std;

class Variant
{
private:
    string result;
public:

    Variant()
    {
    }

    template<typename B>
    Variant(B val)
    {
        result=to_string(val);
    }

    Variant(string val)
    {
        result=val;
    }

    Variant(const char val)
    {
        result=val;
    }

    Variant(const char *val)
    {
        result=string(val);
    }

    Variant(bool val)
    {
        result=to_string(val);
        if (result=="0")
        {
            result="false";
        }
        else
        {
            result="true";
        }
    }

    friend ostream& operator<< (ostream &out, Variant &VResult)
    {
       out <<VResult.result;
       return out;
    }

    friend istream& operator >> (istream &in, Variant &VResult) …
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

In this case, you don't need the assignment operator at all. The default (compiler-generated) version is going to work just fine. This is because your only data member in the Variant class is the string result, which is correctly copied in the default assignment operator.

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

You made a typo on line 61:

glBindBuffer(GL_ARRAY_BUFFER, vertexId);

It should be:

glBindBuffer(GL_ARRAY_BUFFER, colorId);

Also, I think you should be using GL_TRIANGLE_STRIP instead of GL_TRIANGLES. See explanation or this page. You simply cannot have 8 vertices representing triangles (2 triangles = 6 points, 3 triangles = 9 points). You might also try the deprecated GL_QUADS instead (which, in this case, would draw two rectangles, one in front (z=1), one in back (z=-1)).

To draw the complete cube, using your 8 points (8 corners of a cube), you need to use the glDrawElements to provide a array of indices to order and reuse the points to make the complete mesh. For example, this could work:

static const GLsizeiptr PointsCount = 17;
static const GLubyte PointsData[] =
{
    0, 2, 1,
    7,
    4,
    6,
    5,
    3,
    0,
    2,
    3,
    7,
    6,
    5,
    4,
    0,
    1
};


//... everything else the same, until:

  glDrawElements(GL_TRIANGLE_STRIP, PointsCount, GL_UNSIGNED_BYTE, PointsData);

If I have done it correctly (ordering the vertices of the triangle-strip), then it should give you a cube.

Finally, in your draw function, you might want to add a translation, otherwise, you will have trouble seeing the cube because the camera is smack dead in the center of it. You should move back (using glTranslatef) a little bit before drawing the scene:

void draw()
{
    glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glTranslatef(0.0, 0.0, -5.0);

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

That does not make any sense. The assignment operator has to be a member function of the class that is on the left-hand-side of the = sign. Please provide the class declaration in which these operators are defined.

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

Overloading (of function or operators) is done only with the parameters, not the return type. If you have two function with the same name (or operator), same parameters and a different return type, the compiler is going to say that the call is ambiguous (it cannot choose between the two versions). The way that the compiler decides which overload to call is called "Argument-Dependent Lookup" (ADL) or colloquially as "Koenig Lookup" (after the Andrew Koenig who came up with those rules, long ago). As the name implies, the choice of overload is dependent on the arguments (parameters) only.

As far as the rules go between operators and functions, there is absolutely no difference whatsoever. As far as the language rules go, operator overloading is nothing more than syntax sugar (it's nicer to be able to write a + b than add(a,b), but for the compiler, it is only a different way to name a function and call it (with some restriction on the number of parameters)). The overloading rules are identical.

The assignment operator is a bit special because the compiler will use any assignment operator that can do a "copy" (or "move") to replace the compiler-generated versions of it, and it can only be defined as a member function (as opposed to most other operators that are allowed to be defined as free functions (and usually are, for good coding practice)). But, that's it. There is no requirement that the assignment operator should return a reference to …

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

Anyone that is concerned enough about security to commission a pentester would probably not make the blatant mistake of keeping flash players installed on their network's computers. Sounds more like you're trying to write a hack, and it seems you have a long way to go, so I won't be losing sleep over the possibility of your hack invading the world anytime soon.

I wish to help him do a patch (actually why I’s asked), but first chosed to get an exploit that suits that vulnerability.

That makes no sense at all. Pentesting is about finding vulnerabilities in an existing infrastructure, so that they can be patched. There is no point in doing pentesting on a vulnerability you have already found.

If you found a vulnerability in the adobe flash player program, then report it to Adobe, and you may even provide them with a patch. Unless you have bad intentions, this is the only logical next step.

Is the Ruby language a programming or a scripting language ??

Ruby is an interpreted / JIT-compiled language, it says so on the wiki page.

if u do a research on the meaning of pentesting before attempting to make an idiot of urself publicly ?

Says the person who never made it as far as the wiki-page about Ruby.

dat u see me write "the" as "d" (for abbreviation purpose), which u KNOW is dat y u should ask me to start writing in english(rather …

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

Yo mama is so smelly that when she goes through an airport, the sniffer dogs have to go to therapy for post-traumatic stress disorder.

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

Hi, and welcome to Daniweb!

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

the subject must only partake in activities that are legal for them to undertake in their country of citizenship. According to my clients lawyers this is a legally binding contract and any model who agrees to this clause and ignores it is liable to a lawsuit.

I would advise that your clients get better lawyers, if that's what those lawyers say. I'm no lawyer, but that sounds outrageously wrong by any legal standard. Let's examine it a bit:

There is no legal system anywhere that would consider the country of origin / citizenship of a person to establishing the legality of an action. The legality of an act is always determined by the laws of the country / jurisdiction in which the act is committed. It would be outrageous if it was not so. You can't say "I'm Canadian, so it's OK for me to by alcohol in the US at 19 years old.".

The only way that this clause about "country of origin" makes sense is if the agency intends to do the nude pictures in the country where the model lives. In that case, the question would be more along the lines of "are you of legal age to do this in the country you reside".

Then, the part about "legally binding contract" is also weird. A legally binding contract about doing an illegal act? If you sign a contract to kill someone, are you legally obligated to carry it out? That is preposterous. There is …

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

Well, I must admit that I did not research this very thoroughly. But I also find parts of that wiki page very dubious. A lot of it sounds very similar to the arguments that "well, he wasn't really a Christian in his heart", and citing only weak evidence that he was for secularity (which does not mean against religion). Whether it was true belief or not is not very relevant, he sided with and used religion as a means to unite people. For a fascist, anything that will make people blindly follow you, whether it is nationalism or religion, or more often both, is useful, as Lucius Annaeus Seneca said:
"Religion is regarded by the common people as true, by the wise as false, and by the rulers as useful."

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

Last time i checked that is high treason.

Accusing a black person of high treason during the Apartheid is the very definition of irony.

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

I thought Hitler was an atheist (or a rough equivalent of) and wanted to rid Germany of Christianity.

Hitler was a devoit catholic (through his speeches and writings), and accomplished a bit of a tour-de-force in Germany by uniting the protestants (most of Germany) and catholics (Austria and Bavaria) under the military's motto "Gott mit uns" (God with us). This parallels the way some Americans recently started to call the US a "christian nation" (which flies in the face of long-standing divisions between different denominations, when a southern baptist, for example, would never even consider calling a catholic a "Christian"), and the revival of "one nation under God" (which was almost certainly never said by Lincoln).

Also, the Pope supported the Nazis up to the point where the attrocities of the Holocaust were too unbearably embarassing.

You might be confusing Hitler with the Soviets. The bolsheviks were very much against the church (the Orthodox Church) and sought to eliminate it or severely cripple it after the revolution and throughout the reign of Lenin and then Stalin. This was mostly motivated by fact that the orthodox church had a very long history of working hand-in-hand with the Tzars' regimes to oppress the people. Basically, the general sentiment was that the revolution against the tyranny of the Tzars would not be over until the orthodox church was defeated too. Oh, and now, the orthodox church in Russia works hand-in-hand with the oppressive government of Putin, so, I guess the bolsheviks …

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

"country of citizenship" was the term I couldn't grasp!

I don't know what the legal team will say, but I don't think that the country of citizenship really matters in this case. I think that the country in which the material is produced (where the photo-shoot happens) and where the material is distributed is what matters. And also, the legal responsibility is not on the subject of the picture, but on the people taking and distributing it. It is not illegal to pose nude if underaged, but it is illegal to have, take and/or distribute nude picture of an underaged person. Case in point, the "I didn't know she was underaged" defense never holds water in court. A declaration by the model / subject that he/she is above the legal age holds no legal weight, it is always the responsibility of producer / employer to verify the age.

And the nationality or country of citizenship of the subject of the picture has nothing to do with it.

This is the same as with the legal drinking age, it does not matter where you come from (but where you are) or what you "declare" (you can't walk into a liquor store and say that you'll write-up a signed declaration that you are over the legal age!), it is the responsibility of the store clerc / manager to ensure proper verification of the age (within bounds of reason, i.e., checking ID if it isn't obvious that the person is above …

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

With all these insane comparisons I hear from the right-wing of Hitler with atheists, Mandela or Obama, people will start to believe that Hitler was a black atheist communist!

(as opposed to reality: Hitler was a devout Christian, white-supremacist / nationalist, fascist / Nietzscheist, and vehemently and viciously anti-communist)

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

It's a matter of unfalsifiability. If a religion claimed that devotion or prayer could make you live forever, it would get disproven as soon as the first generation of devotees were all dead. But if you claim that the "soul" will ascend to a higher plane (e.g., budhist "enlightenment"), reincarnate into another being while conveniently losing all conscious memory of the past lifes (e.g., hinduism or scientology), or be transported to heaven or hell (e.g., abrahamic myths), then you conveniently avoid falsification because there is no way to disprove it. Any religion or myth that does not follow the basic logic of unfalsifiability will not survive very long, and so, natural selection makes it so that all surviving religions or myths have that in common, i.e., you can never prove them wrong (which also implies that you can never prove them right either).

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

I don't think the OP is talking about a laptop here. I'm pretty sure this is about a desktop computer, given the references to cleaning the motherboard, and having an "external graphics card".

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

Yeah, the full, original quote is this:

"[Les libres penseurs] étaient les plus honnêtes gens du monde et fâchaient les esprits vulgaires en leur refusant l'immortalité. Car le commun des hommes, qui ne sait que faire de cette vie, en veut une autre, qui ne finisse point." -- Anatole France (La Révolte des Anges, The Revolt of the Angels)

Translates to:

"[Freethinkers] were the most honest people and frustrated the people of crude intellect by denying their immortality. For the common man, who doesn't know what to do with this life, wants another, one which will never end."

or (official):

"[Freethinkers] were the most honourable people in the world, and grieved the vulgar minds by refusing them immortality. For the majority of people, though they do not know what to do with this life, long for another that shall have no end."

This is not so much in reference to the topic of this thread (extending this life). The whole book from which this comes revolves around the conflict between free-thinkers and religious traditions. And this passage, in its context, is pointing out the irony in the fact that many religious people (especially monks and the clergy) (or as he says "the common men of crude intellect") seem to find no better ways to spend their time in this life than in devotion to God, and yet they cling so desperately to an eternal afterlife.

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

I would be quite surprised if this was a problem with the CPU overheating. As far as I know (and I'm not an expert), a CPU cannot overheat that fast (few minutes), unless there is significant and visible damage of the thermal paste or a nearby burned circuit. If you have a burned circuit or chip, it would be visible as a burn mark (usually around the "legs" of the chips), and would also have the very distinctive smells of burnt silicon and/or burnt cardboard (from PCB) which is hard to miss (believe me).

And also, thermal paste can lose its efficacy over time, but it is rare that it would just disappear overnight (or even in a few months), unless there was significant tempering (messing with it).

My bet is on the power supply. This is a common "cheap component" in many computers, i.e., the computer sellers often cut cost by putting in very cheap power supplies that barely meet the power requirements of your components (especially if you upgraded something), causing them to fail early. And the kind of failure you describe is very typical of a power supply failure. They often fail by being able to provide some power for a short while, until the demand is too great and they crumble, causing the computer to just shutdown as if there was a power outage. Diagnosing it is a bit harder without equipment (you could open it up and check for burn marks, or you could take …

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

Hi, and welcome!

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

Just to add a few remarks.

The Visual Studio Express edition is free and completely sufficient. You only really need to pay money for development tools if you are running a mid-to-large software company, below that (small company, personal/school projects, open-source projects, etc.) you will find the free tools to be more than sufficient. Also, when it comes to Visual Studio, AD said that it is good for writing Windows GUIs, that's a bit dubious because the C++ library for GUIs in Visual Studio is MFC, but it is being deprecated and phased out. If not using MFC, you have to go to WinForms, which is a part of .NET, at which point you are no longer doing C++, and you will have to move over to C++/CLI or C#, and pretty much kneel down and pledge eternal allegance to Microsoft!

For GUI programming in C++, you should go for Qt instead, either through Qt Creator and/or the Qt plugin for Visual Studio. Qt is far nicer, portable (Win / Mac / Linux), and standard C++.

Another good option for GUI is the VCL (with C++Builder or RAD Studio). There have been ups and downs with that line of product, but now that they have switched to the LLVM/Clang compiler (and have the only distribution of LLVM/Clang that works for Windows, AFAIK, which is very cool), they seem to have been getting back on the right track. However, this is not free (except on trials).

CodeBlocks …

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

What have you tried so far? We don't do homeworks for people here. You have to show some efforts and ask about some specific problems that you are having with your own code.

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

Sorry to hear that. My condolences.

I remember when my dog died, it had quite an effect on me. Mine was a golden retriever. I think I was about 7 years old when we got him, so I grew up with him. He was very old, and died in his sleep one day before he was scheduled to be put down.