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

As I told you in this other thread, the CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH are environment variables, and they contain a list of paths that cmake ought to use in order to find the libraries on your system. You should definitely not set them as command-line argument to cmake. What is the output if you simply run this command:

cmake ..

In other words, without any options at all. All the options that you have put in the command line as per your last post, were wrong. You shouldn't define individual tokens like ZLIB_INCLUDE_DIR in the command-line. All your libraries seem to be installed on the C:\ directory, there should be not problem for cmake to find them automatically, as long as you leave the variables CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH intact, or make sure that C:\ is listed in them, when you look at their values in the environment variable listing of your computer.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster
  1. Make sure that libpng and zlib are installed on your computer.
  2. Make sure that FindPNG.cmake module is installed on your computer (should be by the default cmake install). To find it, make a file search for the file name "FindPNG.cmake", and you should find it in CMake's "Modules" directory.
  3. Make a small test to make sure it is found correctly, i.e., try this CMakeLists.txt file:

    cmake_minimum_required (VERSION 2.6)
    project(PNGTest)

    find_package(PNG REQUIRED)

    message(STATUS "LibPNG package was found with include dir: '${PNG_INCLUDE_DIRS}'")

  4. Run a clean cmake configuration on the code that you originally wanted to compile.

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

In the function you just posted, you forgot to handle the misalignment at the end of the pixel rows. This should work:

void JNIData::FlipBytes(void*& Result) {
   unsigned long Chunk = (Bpp > 24 ? width * 4 : width * 3 + width % 4);
   unsigned char* Destination = static_cast<unsigned char*>(Result);

   unsigned char* Source = &BufferPixels[0] + Chunk * (height - 1);

   while(Source != &BufferPixels[0]) {
      std::memcpy(Destination, Source, Chunk);
      Destination += Chunk;
      Source -= Chunk;
   }
}

As for the earlier version (in original post), I would just forget about it. The monkey business with this line:

int Offset = TopDown ? (height - 1 - I) * width + J : I * width + J;

looks very suspicious to me. If anything, you should probably use a strategy similar to that of the other version, i.e., go backwards in the source image, and forward in the destination image.

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

I think your question is just too broad and too narrow at the same time. I say too broad because one could interpret it as just "I want to learn about software engineering". And I say too narrow because you make references to the specific problem of linking, using and building external libraries, which is a very practical issue (as opposed to a "computer science" issue). I personally don't really know what to make of it.

Learning to use external libraries and understanding the compiling-linking process for a given language / platform / build-system is something that you just pick up as part of the process of learning to program in those tools. There are some guidelines for sure, but by and large this is just practical know-how and common sense. My advice on that side of it would be to just look at how certain projects are setup and what their guidelines are. Many open-source projects (the good and large ones, at least) have a set of guidelines and procedures about the overall organizational issues, code reviews, unit-test policies, release schedules, version control, etc. Try reading some of them a bit, just look for them in the "developers -> guidelines" section of the project's webpage. I don't know of any books on this topic specifically. Some general C++ books will talk about some of these issues a bit, like C++ Coding Standards or Exceptional C++.

Other than that, I can't really recommend anything more. In …

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

First, these are environment variables. So, if you need to set them, set them like you do with any other environment variable.

Second, why do you want to modify those variables? These are not things that you normally have to temper with, i.e., these are usually set correctly at installation of cmake, and they relate to how cmake functions overall, these are not variables you need to temper with for individual projects. The CMAKE_INCLUDE_PATH defines the different system's paths in which the CMake program (not the compiler) will look when it is instructed to look for a particular set of header files corresponding to a package required by your source code, i.e., when issuing a find_path() command in a CMakeLists.txt file. Similarly, the CMAKE_LIBRARY_PATH defines where to look for when CMake tries to find an installation of a required external library, i.e., when issuing a find_library() command in a CMakeLists.txt file. Normally, these environment variables are basically set to the few system paths in which such packages (headers and libraries) would normally be found. If you happen to install some libraries in very weird places (why would you do that?), then you might have to add these very weird places to these environment variables. But that's not something you should do anyways.

These variables are not those corresponding to "include paths" or "library paths" typically found in the build configurations of IDEs. CMake is made to automatically search for the required include paths, library paths, and libraries to …

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

These are a lot of questions. I was actually planning on writing a tutorial explaining all this stuff. I'm a bit busy right now, so, in the mean time, I'll briefly answer your questions.

1- Preprocessor copies the contents of included header files into the source code file.

Yes, among other things. The preprocessor will also evaluate all the conditionals (e.g., #if, #elif, etc.), prune away the comments and other fluff that is irrelevant for compilation, perform the MACRO substitutions, perform tri-graph substitutions as well (if required), and process all the compiler pragmas.

Q1: So how would the C++ source code file look after such step?

That preprocessed source file probably never exists in actuality (depending on the implementation of the compiler), but if it did, it would probably look like a large cpp file (with all headers copy-pasted into it), which is clean of any conditional compilation blocks or comments. One could easily imagine that blank lines would also be pruned away. In any case, it would still be perfectly recognizable C++ code, which the pre-processor will not touch.

Q2: Is the preprocessor a program?

In theory, it could be a separate program that runs before the compiler runs, and some compiler suites do that. However, many compilers don't do that, and for a couple of good reasons. First, things like #pragmas are there to configure the compiler (not the pre-processor) and thus, they need to be registered with the compiler while the …

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

I like it. Not sure if it'll become my go-to place, time will tell. I actually kinda like the "Recommended" page more, for the fact that it lists all the threads of my favorite forums in one listing. Can you manually mark some forums as "favorite"? Some forums are not very active or I'm not overly active in them, so they wouldn't percolate up to "favorite" status based on my posting statistics, but I still navigate to them regularly, just to see (these include "C", "Linux / Unix", "Computer Science", "Game Programming", etc., which are either not very active or I only occasionally feel worthy enough to post on).

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

The same as its English meaning: a lump of anything.

As far as I know, the word has no special meaning in C++, and I would know if there was. It just means a piece of memory or code or anything.

Do you have a specific context in which you read or heard the word being used?

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

UNiplexed Information and Computing Service (Unix)

Disk Operating System (DOS)

Berkeley Software Distribution (BSD)

GNU's Not Unix / Linux (GNU/Linux)

Free Real-Time Operating System (FreeRTOS)

General Motors and North American Aviation Input / Output system (GM-NAA-IO)

University of Michigan Executive System (UMES)

Dartmouth Time Sharing System (DTSS)

Эльбрус-1

Keyboard Entry Read, Network, And Link (KERNAL)

Windows 1.0

...
...

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

If your matrix is 96x48, then you cannot invert it. You have to solve the linear least-square problem, which leads to computing the left Moore-Penrose pseudoinverse. This can be calculated in a number of different ways, the more generic of which is the QR-decomposition, or the Singular Value Decomposition which is a lot more expensive computationally but more robust if the matrix is rank-deficient (or nearly so), but in this case, it is usually better to use an RRQR decomposition. These are all basic numerical methods that you will find in just about any matrix library out there, including mine.

Normally, however, you rarely calculate an inverse or a pseudoinverse of a matrix, because most of the time what you really want to do is solve a system of linear equations (either determined, under-determined (min-norm problem), or over-determined (least-square problem)). And if you are solving a system of linear equations, you should solve the system of linear equations directly, not through the calculation of an inverse or pseudo-inverse. The systems of linear equations are solved with the same method as for finding the inverse (i.e., the inverse is just the result of solving a system of linear equations where the right-hand side is the identity matrix), but it is quicker to do it in one step. And for that reason, most matrix libraries will provide both functions (and several others related to them). One example is

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

Usually, fixing the indentation will reveal such problems:

            //ticket purchase while loop
            while (ticType == 1 || ticType == 2 || ticType == 3)
            {//while the ticket type equals 1, 2 or 3

                if (ticType == 1)
                {//if purchase toddler ticket
                    cout << "You have selected to purchase a Toddler ticket. "
                    "How many Toddler tickets would you like to buy?" << endl << endl;
                    cout << "Please enter the number of tickets (1-10): " << endl << endl;
                    cin >> numTic;
                }
                if (numTic > 0 && numTic <= 10)
                {//if number of toddler tickets is between 1-10
                    cout << "Do you have a discount coupon today?" << endl;
                    cout << "Enter 1 for YES or 2 for NO: " << endl;
                    cin >> discountQues;
                }
                if (discountQues == 1)
                {//if customer has a discount coupon
                    totalCost = (TODDLER_TIC * numTic) - (TODDLER_TIC * numTic * DISCOUNT);
                    totalNumTic += numTic;
                    totalRevenue += totalCost;
                }
                if (totalNumTic >= MAX_SEAT_COUNT)
                {//if the total number of tickets equals the maximum seat count
                    extraTic = totalNumTic - MAX_SEAT_COUNT;
                    cout << "SEAT CAPACITY          EXTRAS            TOTAL SOLD" << endl;
                    cout << MAX_SEAT_COUNT <<       extraTic <<       totalNumTic;
                    cout << "TODDLERS               JUNIORS           SENIORS";
                    cout << toddlerTicTotal <<      juniorTicTotal << seniorTicTotal;
                    cout << "GROSS FOR TODAY: $" << totalRevenue << endl << endl;
                }
                else
               {//else the total number of tickets does not equal the maximum seat count
                    cout << "Type of ticket(s):Toddler Ticket(s)"<< endl;
                    cout << "Number of ticket(s):" << numTic << endl;
                    cout << …
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

What would you say is the steepest part? Generally speaking, that is.

For the complete beginner, the first major hurdle is just understanding how programming works, i.e., basic procedural programming concepts like variables, arithmetic, pointers, arrays, loops, algorithms, and functions. But that's not a problem for someone with some experience in any other language. Then, the second hurdle is dealing with the construction of a software architecture, which includes object-oriented programming, polymorphism, and resource management strategies. Some languages like Java or Python kind of skip that hurdle by making OOP a requirement by design of the language, broad-brushing everything as polymorphic, and handling memory management automatically. In C++, you have to learn to use these concepts at the right places (mix different paradigms) and be able to implement them correctly, and while you are still learning to do those things, there can be a lot of suffering in the form of memory corruption bugs and other nasty things. But once you have a handle on that, and you are somewhat familiar with basic uses of templates, and you are good at employing the C++ standard libraries (especially the STL), which all go hand-in-hand pretty much, then everything is as easy, if not more, than in any other language, including doing GUI programming.

Those who can't get past the first hurdle are not made to be programmers. And those who can't get past the second hurdle will probably never become expert programmers, but might be proficient programmers (good enough …

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

A few hundred bytes is the least I can expect to deal with.

By a few hundred bytes, I didn't mean that the entire document is only a few hundred bytes, but I meant that the chunks that make up your "piece table" (i.e., the pieces) are a few hundred bytes each, at least. This is basically to the point of how fine-grained your pieces are. On the one extreme, you can make a "piece" to represent each individual addition / subtraction of text, which would probably average at a few dozen characters each (e.g., like what would typically show up in different colors when you turn "track changes" on in MS Word). On the other extreme, you would store the entire text in one continuous (gap) buffer. Neither of these solutions would be good when working with a large document. The optimum would certainly lie in the middle somewhere, i.e., as a sequence of (gap) buffer segments which are maintained to a reasonable size (merged when shrinking too small, split when expanding too big), which I would roughly estimate to be around 1000 or 2000 characters on average.

If it turns out to be piece-table based, then that would be the icing on the cake.

I doubt that. The LaTeX format, which I encourage you to learn / play-with, is essentially in the form of a tree. This is also similar to the way HTML works. And I think that the docx format for MS …

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

I don't know much specifically about a word processor, but I would certainly expect all of them to be using some form of a MVC pattern (Model-View-Control). I would also expect that all the word processor use some form of a markup language to represent the actual text along with all the meta-data (formatting, images, labels, cross-references, etc.), that's the "Model". This markup'ed text would certainly be stored internally to the word processor in the form of a graph, not just a simple buffer of text characters. Creating a complete specification for such a markup language, even for simple documents, is quite an endeavour. I would recommend you pick one that already exists and base your graph structure on that. Then, the "control" part would be merely about creating functions to do graph surgery, which has its challenges, but at least, it is incremental and modular in nature.

I also don't like typical word documents like MS Word or LibreOffice, and for that reason, I, like many others in academic fields, use LaTeX instead. LaTeX is usually written directly in LaTeX commands, as opposed to using some word processor. I would highly suggest that you base your markup language on LaTeX (or a subset of it), that's gonna take care of a significant part of this project. On that front, you might want to take a look at LyX, which is a simple word processor based on LaTeX.

By the way, I don't buy your arguments about using …

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

Did you try installing the newer version of the same lib. That is, try $ sudo apt-get install libdb5.1++-dev

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

What about using a function templates like these ones:

template <typename T>
T read_value(char*& ptr) {
  T result = *(reinterpret_cast<T*>(ptr));
  ptr += sizeof(T);
  return result;
};

template <typename T>
void write_value(char*& ptr, const T& val) {
  *(reinterpret_cast<T*>(ptr)) = val;
  ptr += sizeof(T);
};

And then do this:

char* Data = static_cast<char*>(GivenPtr);

char* cur_ptr = Data;

switch( read_value<int>(cur_ptr) ) {
  case OBJECT:
  {
    // ... 
    double some_value = read_value<double>(cur_ptr);
    //... etc..
  };
  break;
  case OBJECT2:
    // ...
};

How can I tell what Indicies to write to after each cast?

Whenever you read/write something from the buffer, increment the pointer by the size of the value you read/wrote. This is easiest with a function template as I showed above.

Is there a way to just write it straight to a char* and then read straight from that char?

That's pretty much what you are doing already. The type casts will not really cause any overhead, beyond that of breaking word-alignment.

Better yet, can I do this with a void?

It is preferrable to do it with a char* because it has a guaranteed size of 1 byte, while a void has undefined size, which is going to cause trouble when doing the pointer incrementing.

triumphost commented: Ahh :o I never thought about templating it :o Best solution! +6
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

A queue is a very basic concept which requires only a few functions. The idea behind a queue is just to be able to add elements to the back (push), remove elements from the front (pop) and inspect the elements on either end. This is an abstract and functional concept that one can use in an algorithm. However, there are infinitely many ways to implement that basic concept, and in most cases, the way the queue is implemented has very little or no impact at all on the algorithm that uses it. And thus, you would normally write the algorithm in a generic way that can handle any implementation of a queue. But, because different implementations of the queue concept might not be able to supply the same set of functions that most STL containers provide (deque, list or vector), you don't want to link the queue concept to a container like deque directly. Instead, you say that a class implementing the queue concept should have four functions (front(), back(), push(), and pop()) which makes that class a "queue", anything more is irrelevant. This way, just about any implementation of the concept of a queue will be able to comply to this concept, and you can write generic algorithms that only rely on these four functions and you will be able to swap out the type of queue you use for any other type, without any trouble. So, this is why the "queue" concept exists, independently of the deque container …

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

Being a big C++ advocate, it would be hard for me not to recommend it. I would certainly say that using Qt (with QtCreator) in C++, doing that project that you envision will be a walk in the park, if you are at least somewhat comfortable already in C++. The learning curve is really the only obstacle to C++, once you are passed the steepest part of it, almost everything is very easy. But if you are familiar with things like assembly programming, that hurdle shouldn't be too hard to overcome.

And also, generally, most assembly programmers I've met are happiest when they are in control of the low-level details and are in a predictable run-time environment (i.e., they are generally OK to work in C, and a little uncomfortable in C++, but can't stand anything "higher" than that). That could be a problem with Python. I know that is a little bit of a problem for me, I love the style and ease of use of Python, but I also know how important certain optimizations are, like streamlined memory traversal patterns and locality of reference issues, that I have a hard time in an environment that gives me little to no control over that. But, of course, the application you have in mind is not anywhere near being performance critical or heavily algorithmic (which is the kind of thing I do), so all these issues don't matter, but be aware that it might be an unpleasant feeling, if coming …

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

Writing a custom allocator is just about obeying the interface specified by the C++ standard. It's not really that hard at all. Of course in order to be able to use a custom allocator, you need to specify it in the instantiation of your STL containers, and if it is stateful you need to construct the allocator during the construction of the STL containers.

As for tutorials / guidelines, I think that pretty much every C++ book that talks about the STL has a chapter or section that talks about creating a custom allocator, many of which use the example of a memory pool allocator. Bjarne Stroustrup has a section about allocators in "The C++ Programming Language" with a memory pool example. Then, I wrote a quick and simple example of a no-init allocator as an answer to this SO thread. Scott Meyers talks about allocators in his items 10 and 11 for "Effective STL". Then, you'll find chapters on allocators in books like "C++ Programming with the Standard Template Library" (David R. Musser) (Chapter 24), "The C++ Standard Library: A Tutorial and Reference" (N.M. Josuttis) (Chapter 15), and in "Modern C++ Design: Generic Programming and Design Patterns Applied" (Andrei Alexandrescu) (Chapter 4) (warning: this last book is pretty advanced).

What is hard about creating a custom allocator is making sure it is efficient and robust (reliable), let alone be worth it, because very often the conjunction of OS memory handling mechanisms, the optimizations within the heap implementation, …

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

I think I can make it as solved, can't I?

You're the OP on this thread, you can mark it as solved whenever you are satisfied with the answers. You don't have to ask permission.

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

I saw Prometheus a week or so ago. It was very disappointing. The only good thing in the movie is the awesome Noomi Rapace. The plot was weird and thrown together very poorly. There were too many of those obvious and unrealistic setups, like a guy deciding out of the blue that he doesn't like to see the "gross" dead alien so he decides that it is a better idea to leave his group and go wondering about alone in a dark cave on an alien planet... surprise!.. he gets killed. Then, the scientific realism is just appalling. I don't mind when Sci-fi movies have warp drives, phasers or teleporters, and I don't mind when writers construct some imaginative twists to scientific facts to create something interesting for the plot of a movie, but what I can't stand is when they propose something that is in complete contradiction to all scientific facts (in this movie: evolution), and do so very casually (like its no big deal), just so that they can make big ugly monsters pop out of mud-puddles (which isn't particularly creative or interesting, very B-movie). And the religious preaching in that movie was just obnoxious. I think they missed the mark completely by making a film that only people who are scientifically illiterate and very fond of religious mumbo-jumbo can appreciate (without being extremely irritated by it), but doing so in a Sci-fi genre, that doesn't make any (commercial) sense to me at all.

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

does gcc have graphics library

Not by default. GCC only includes the standard libraries (C/C++ standard libraries). For everything else, you need external libraries. The nice thing with Linux is that you can very easily install those external libraries and start using them right away, with little trouble. In your package management software, you will find libraries marked as "dev" or "devel" which means that it will install development files needed to write applications for them (usually including library binaries (.a and .so files) and header files, in the standard system directories /usr/lib and /usr/include, respectively). Most libraries will start with the prefix "lib" (e.g., such as libsdl1.2-dev for SDL development files).

I researched on the libraries that l can use eg sdl, openGL, what l wld like to noe is it possible to code using gcc in linux

For SDL, you should look up "libsdl" on your package management system and install all the "-dev" (or "-devel") that seems useful (probably libsdl1.2-dev, libsdl-image1.2-dev, and libsdl-gfx1.2-dev). For OpenGL, it should already be installed by whatever graphics driver you have, including its development files. You can #include "GL/gl.h" and add -lGL to your compilation command, and it should work. Just follow simple SDL-OpenGL tutorials, like these ones and then these OpenGL tutorials.

If I may suggest an additional library to look at, I would recommend looking at Coin3D. This is an open-source implementation of OpenInventor (a sort-of extension of OpenGL that …

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

Is there any default user name n password for ubuntu???

Read my answer above. Short answer, write sudo su in the terminal, and enter your user password, then you can reset the root password using the passwd command.

Darshan5 commented: Thanks, Mike... +0
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

For the most part no, there is no penalty. The x64 instruction set is an extension to the x86 (32bit). This means that all the x86 instructions are still supported and executed natively by the CPU, i.e., there is no "virtual machine" or other emulation layer. There is no reason for the 32bit instructions to be executed slower than the 64bit ones. There might be some negligible overhead, but nothing noticeable.

The WoW64 thing mostly pertains the OS environment outside the application (virtual addressing, using drivers, kernel calls, etc.), but it doesn't get in-between the application and the CPU. In other words, it makes the application think that it is running in a classic Win32 environment, and since all those OS-related calls are always very slow, the overhead created by wow64 is negligible (just executes a few arithmetic conversions, which is nothing in comparison to making a kernel call).

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

"In recognition of this intent, a single-argument constructor in C++ is called a copy constructor."

That statement is false. Here is the standard definition, from Section 12.8/2:

A non-template constructor for class X is a copy constructor if its first parameter is of type X&, const X&, volatile X& or const volatile X&, and either there are no other parameters or else all other parameters have default arguments (8.3.6).

Then, all constructors that can be called with a single argument are called (explicit) converting constructors ("explicit" only if marked with the attribute explicit). The copy-constructor (and move-constructor) is a special kind of converting constructor.

So, the authors of the book were wrong, you were right.

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

Your user password is not the same as the root password, at least, not by default. The install will give your user account administrative rights (like doing sudo commands, and installing software), but it doesn't make your user account the "root" account. The root account is issued a randomly generated password, that is to ensure that a hacker cannot easily login remotely to the root account by cracking an easy password.

In order to do a su command, you need to first issue a sudo, in other words, write this in the terminal:

$ sudo su

and enter your user password.

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

Another simpler solution that doesn't involve a live CD and all this fiddling with the system files is to simply boot into single-user mode. I had this happen to be a couple of times, grabbing a dusty old Linux box that noone had the password for, booting into single-user mode and just resetting the password with passwd command takes about 5 minutes at most.

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

I can already picture it:

After a hard day's work on a new warp drive for the ferry ship to Europa (Jupiter's moon), I drive my personal flying machine back home at super-sonic speed. Before I know it, I'm sitting in my entirely automated home, and I decide I feel like slashing some monsters. So, I grab my super-powerful quantum computer, plug it into my cortex implant (via a pico-USB cable) to enter the virtual world of Diablo XIV, but then, I read: "Please wait while Windows 28 is installing 143 critical updates. Do not unplug your implant from the computer. Only 87 minutes remaining..."

np complete commented: This is funny :P +0
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Welcome to Daniweb! Hope you'll like it.

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

In the private message page, there should be three tabs: "Inbox", "Outbox", and "Send New PM". However, I think there is a lower limit of post counts required to be able to send PMs (it's an anti-spam measure, i.e., people coming in, making fake accounts, and sending tons of spam through PMs). I think the limit is either 5 or 10 posts on threads.

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

First, let's get the obvious out of the way. I must assume that although the data member is const, it does not have the same value for all objects of that class. Because if that were the case, the trivial solution is to use a static const data member.

So, I imagine you have something like this toy example:

class Angle {
  public:
    enum unit { radians, degrees, turns };

    double Value;
    const unit Unit;  // this is the const data member.

    Angle(double aValue, unit aUnit = radians) : Value(aValue), Unit(aUnit) { };
    Angle(const Angle& rhs) : Value(rhs.Value), Unit(rhs.Unit) { };

    Angle& operator=(const Angle& rhs) {
      Value = rhs.Value;
      Unit = rhs.Unit;   // ERROR: 'const unit' cannot appear on the left-hand-side of an assignment.
      return *this;
    };

    // ..
};

In other words, you have some object parameter that you want to set upon creation of the object, and then leave fixed from that time on-wards. At least, that's how I understand it.

My current solution is to use a pointer to a const object that lives in a more global scope. While the pointer itself is not constant, at least the underlying object is const.

It sounds pretty bad. Again, excluding the idea that the value in question is the same for all objects (in which case, the trivial solution is a static data member), I must assume that you need some sort of vector or array storage to store all the values, one for …

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

My preferred method is to use stringstream. As in:

#include <iostream>
#include <sstream>

using namespace std;

int main() {
  stringstream ss1("42");
  int value;
  ss1 >> value;          // convert string to int
  cout << value << endl;

  stringstream ss2;
  ss2 << value;          // convert int to string
  cout << ss2.str() << endl;

  return 0;
};

Otherwise, you can use the atoi / itoa functions, or the sscanf / sprintf functions.

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

You might wanna update the wikipedia page on Daniweb, I think the info on it is getting a bit old now.

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

Congrats Dani! That's quite a landmark! You can now boast about how Daniweb has more than a million members!

I think the facebook login made a huge difference. I remember observing the number of member some months ago thinking that it was kind of stalled in the 980k or so. But since the facebook login, it went up to 1M before I could even notice!

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

Where to build the binaries: C:/CodeBlocks/MinGW/bin // this could be a really dumb move as I'm not sure where these binaries should go?

You should not do that, definitely not. Usually, when working with cmake, you want to create at least three folders: src, build and bin, for the source code, the temporary build files (cmake and make cache files), and for the resulting binaries, respectively. For example, if your project is called "MyProject" and is directly in C:\MyProject folder, then you should create three folders, C:\MyProject\src (the top level folder containing all the sources), C:\MyProject\build (or C:\MyProject\src\build) (which is where you execute the cmake and make commands), and C:\MyProject\bin (where the binaries will go). When building libraries too, it is often good to output them into another directory too, e.g., C:\MyProject\lib.

So, the directory you should specify in your CMakeLists.txt for the output should be those I gave about, or something similar. The point is to keep the source file folder clean of any binary files or temporary files resulting from the build (this is called an "out-of-source build"), and put all the resulting in one separate folder. This makes for a much cleaner environment, and is especially important if you eventually decide to use a version control system.

I generate the makefile (correctly MingW is selected in configuration) and I get the below error. Have I done something wrong above?

The error reports that the find_package command in cmake was unable to locate the …

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

discussions with behaviorists always seemed to end like that.

Here's salient quote:
"Our understanding of human behavior is at the same stage as physics before Galileo." -- Noam Chomsky

@GrimJack - I believe Mike cited the French quote.

Actually, it was a French-canadian way of using a French saying.

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

i need certain details of robotics

Then you should ask about what you want to know.

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

It depends. There are generally three kinds of libraries in C++: shared libraries, static libraries and header-only libraries.

In the classic plain C++ world (e.g., basic OOP code, no template), the library will be made up of header files that declare classes and functions, and corresponding source files that implement the functions and classes. If you want other people to use the library without having to import all the source files into their "project" (e.g., the list of source files in your IDE), then you need to compile all the source files into a library, which can be either static or shared (also called "dynamic-link library" in Windows lingo).

A static library is essentially just a raw collection of compiled code (i.e., each source file is compiled separately into an object file (.o or .obj extension, usually), and then they are collected together in one static library file). A user of the library would write his code, including the headers from your library, and link to that static library (i.e., to fetch the compiled code that implements the functions he uses). With a static library, the linker will grab all the relevant compiled code from the static library and copy it into the user's executable. At this point, the executable is entirely standalone and does not require the users of that application to have the library installed on their computer.

For a shared library (or dynamic link library (DLL)), the library is technically-speaking more like an executable than like a …

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

Is this just wrong or are they being cautious about mixing C and C++?

No, it is correct. When you are using a compiler like GCC (within MinGW distribution), this is actually the GNU Compiler Collection which includes both a C compiler and a C++ compiler (at least, but often a few others like Fortran, Ada, and possibly Objective-C and Java compilers). What Ancient Dragon explained about extensions *.c vs. *.cpp is that CodeBlocks will invoke the gcc.exe program to compile all the source code, and that program is made to check the file extension and compile the code accordingly with the appropriate compiler (i.e., its C or C++ compiler). GCC uses the same backend for all its compilers and it uses one linker for all linking tasks, so, once individual source files were compiled, it doesn't make a difference from which original language they were compiled from, they all just link together (as long as they have the appropriate extern "C" wrapping in the headers in between C and C++ code). So, SQLite is correct in saying you can't compile their code with a C++ compiler, only with a C compiler, but that is already what is happening under-the-hood when you add the C code to your project.

The more pedantic way to do this is to take all the C code from that external library and compile it into a static or shared library, and then link that static library to your compiled C++ code. It …

daino commented: Thanks for the effort. Great Answer. +2
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Sure. Use an archive manager application. For KDE, the standard one is Ark. For Gnome, the standard one is File Roller. Both open-source and installable from repositories, and they will certainly allow you to preview text files. I know that Ark is well integrated with other KDE programs to allow you to open just about any typical document you'll find in a tarball.

If you are talking about doing this in a terminal, then you just need use the tar command, which has many options, including that of filtering through bzip2 compression/uncompression. For more details, type man tar in your terminal.

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

Välkomna! Jag är altid glad at se an annan svensk pâ Daniweb!

As a C++ advocate, I'd hope you'd give it another try. In any case, have fun! And I hope you enjoy our community!

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

Your best bet is to use Poppler because PDF is a complex format with no easy way to extract text from, you need to rely on a library made to load PDFs, like Poppler. There is a utility called pdftotext which does exactly what you want. You can use it in a bash terminal (Unix / Linux) for example to save the text to a file:

$ pdftotext my_file.pdf > my_file.txt

Or to count the number of occurrences of the word "the" in a pdf file:

$ pdftotext my_file.pdf | grep -w -o the | wc -l

Within a C++ program, you can simply issue a system() call with commands like the above, or you can use the libpoppler C++ API directly.

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

(1) The money invested to produce those capital gains has already been taxed once, so you're really talking about taxing it twice;

Taxes are essentially applied to any money transfer, that's how it works. It's not about how many times a given chunk of money has been taxed. Taxes are like a toll paid to the government at every transfer of money, from employer to employee (as payroll tax), from company to investors (capital gain), from buyer to seller (sales tax), etc. If you don't like this system, that's one thing to argue about, but you cannot say "this money was taxed twice" because that makes no sense from the perspective of what taxes are, by definition.

The problem with arguments about why this or that particular kind of tax should be lowered or abolished is that it leaves a route for money to travel untaxed or at a reduced tax rate. And those who have the means to choose different paths to route their money into their pockets or their tax-haven account will choose the path for least taxation.

(2) Over longer terms, most of the returns from capital gains are due to inflation.

Then adjust the capital gain tax to be valued against present value. I agree that the inflation part of the capital gains should not be taxed as it is more a part of the principal than a part of the revenue. But the problem with the capital gain tax is not …

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

and they never explain what is the gap made of. Or in other words: what's the content of the gap?

Wealth. The "gap between the rich and poor" almost invariably refers to the unequal distribution of wealth. You can measure it in a few different ways, mostly as income distribution or as cummulative wealth distributions. As income distribution, imagine you take all the people in the country, sort them from least income to most income along the x-axis of a graph, and then draw a line that follows the income from individual to individual data points. In a "perfectly equal" society, that line should be perfectly flat (i.e., everyone has the same income), but in a completely unequal society, the line would look like a hockey stick (i.e., the great vast majority are dead-poor, while a few at the upper end have everything). In case of a hockey-stick curve, there will be a marked jump at one point, and you can say that is the gap between the rich and poor. More accurately, however, you can take the cummulative (integral) of that curve to get a cummulative distribution. In other words, each point on the curve represents how much you and everybody poorer than you make together (cummulative), often measured as percent of GDP. Now, the "equal" line becomes a straight line (constant slope) on a cummulative distribution, and the more unequal the distribution is, the more that line curves downwards (concave). You can measure that level of …

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

The problem is that you never initialize the value of "finalvalue", neither in the main() function nor in the sin/exp functions. You should simply add finalvalue = 0.0; at the beginning of each function (sin and exponential), and that should solve your problem. The rest looks fine to me.

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

can the same source code run in different operating systems ? how?

The same source code can be compiled for different operatings systems (and overall platform). There are about 4 kinds of "source code": the standard library, the operating system's API, third-party libraries, and your own code. The standard library is provided to you along with the compiler (GCC, MSVC, ICC, etc.), and it was either specifically made for the target platform (e.g., MSVC) or configured to work well on the target platform (e.g., GCC). The functions and classes available in the standard library are, well, standard, so they apply across the board, all conforming compilers must provide it on each platform that they provide compilers for (with some exceptions for restricted environments like micro-controllers).

The operating system's API is obviously platform-specific. If you need to use it, you must be aware that it will only work on that platform. If you want to do the same thing (e.g., open a network connection) on different platforms, you must use conditional compilation, typically looking like this:

#ifdef _WIN32
 // put Windows-specific code here..
#else
 // put Unix/Linux-specific code here..
#endif

Third-party libraries (or external libraries) will vary depending on whoever wrote them. Most library implementers try to be as cross-platform as possible with their implementations. The way to do that is to use only use standard libraries and other external cross-platform libraries, and use the above techniques whenever a operating system API feature is needed …

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

Give 5 type checks

...

My issue was that I did not know what other types of checks

There is a huge difference between saying "type checks" and "types of checks". The answer vijayan121 gave was specifically referring to "type checks", in other words, a set of conditions that the compiler must verify about the declarations (types) of the variables (identifiers) involved in the expression given. This is how I originally understood the question too. If you are talking about "types of checks", then it is a very different question, with a very different list. Vijayan121's comprehensive answer really just involves two types of checks that the compiler does: type checking and overload resolution (or argument-dependent lookup). But as a programmer, there are many more things you can verify to ensure the statement in question is correct (including a range check, that there is no involuntary implicit conversion happening, re-entrance, making sure f() does not store or return a pointer / reference to a by-const-reference parameter, etc.).

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

If you don't have the root password, but you have sudo privileges on your user account (i.e., you can run commands under sudo by entering your user password), then you can simply run this to become root in the terminal:

$ sudo su

And then, you can change the root password with the passwd command.

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

As a chaser for vodka I like hot & very strong black tea: one draught of vodka, then 2 or 3 draughts of tea (no any sugar!!! by no means!!!). As a snack for it: smth very light & salty; e.g., caviar, fish, meat (and again, by no means any fruits, vegs, bread etc).

This couldn't sound any more Russian, black tea + vodka + caviar.

What's the best russian dish? In your opinion.

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

Looking at another interest of mine, being Robotics at the moment at University which kind of combines all of my main interests...

If you're interested in robotics, you'll have to make a choice about which way to go about it. Because it is a multi-disciplinary field (which is what I love about it), there are many aspects to it, essentially, hardware and software. The hardware side is usually called "mechatronics" (fusion of mechanics and electronics / electromechanical devices like actuators and sensors), and would normally require that you go down the path of getting a B.Eng. degree in either mechanical engineering or electrical engineering (or something in between, if you find a good mechatronics program). The software side is usually called "automation", and would normally require that you do something like a software engineering or computer science degree. Few people work in robotics without having at least a Masters degree, so that's something to be prepared for too, and that's also a good time to step to the opposite side (hardware vs. software) of what you did the undergraduate degree in.

maths may be an issue though.

Be warned, whatever you do in robotics, there is a ton of programming or a ton of math, and usually both. The programming is mostly low-level C and high-performance C++, with some interludes with languages like matlab or Java (for tools or testing things out). The math is mostly probability theory (artificial intelligence stuff), computer sciency things (like graph …