rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Have a look at Linux from Scratch

Just what I was going to suggest. http://www.linuxfromscratch.org/

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Have a look in the manual that came with your motherboard. That should tell you all you need to know about what CPU's it supports!

Or go to the MSI web site and check the board specifications. They should say exactly which processors they support.

Personally, I prefer Intel boards. They are compatible, reliable, and well supported.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I like Jewels, Angry Birds, and Solitaire. Mostly I play Jewels and Angry Birds when I am bored.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

So, you are trying to run the phone as a mobile "hot spot"? Does it support USB tethering? What mobile OS does the phone run?

hmidaboy31 commented: suport wlan nokia n79 +0
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Sounds like the LCD back light is failing. Take it in to a repair depot.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What OS are you running?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

2. You have an extra ')' at the end of the function declaration.
The rest are likely a result of this error.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Why convert to string? If you want to print to terminal, just output it to cout, as in:

int i = 999;
cout << "i == " << dec << i << endl;
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Ah, CRTP - been there, done that, didn't know what it was called... :-) As usual Mike has a huge base of useful knowledge! :-) Mixins I'm familiar with, and that can also be a very useful pattern, but easily misused.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I agree with thelamb that Stroustrup's book is more of a reference work. Well worth keeping on the shelf handy for quick sanity checking, or getting into stuff in depth - that's what I use my copy for, along with the Annotated Reference Manual (ARM). I've been programming in C++ for 20 years, and I still use them regularly.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

There is the non-associated global operator ::new that returns a void* type, but there is (implicit) typed operator new for all data types. So, in your case, calling "new int" will indeed return an integer value, and "new int[10]", will return an array of 10 integers.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Along with the memory requested (10 bytes in your example), there is also other allocation overhead such as so that the number of elements is recorded, so when you do this:

delete [] a;

The system knows how many elements to free. This is especially important when you allocate an array of class objects that need to have their destructors called when you destroy the array.

All that aside, memory allocation and management is a doctoral thesis subject. Been there, done that. I spent a couple of years researching reference counting memory management routines for C and C++ back about 10-15 years ago. I wrote a reference-counting (time-deterministic) garbage collector for C++ that is in use today to manage major manufacturing systems.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Along with the memory requested (10 bytes in your example), there is also other allocation overhead such as so that the number of elements is recorded, so when you do this:

delete [] a;

The system knows how many elements to free. This is especially important when you allocate an array of class objects that need to have their destructors called when you destroy the array.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

This is when you learn how to use a debugger...

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Since you are in the C++ forum, I assume it is collaboration, as in CRC. Here is an article from the wikipedia about that: http://en.wikipedia.org/wiki/Class-responsibility-collaboration_card

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Usually I do this sort of string <-> enum mapping with an array. Example (using your stuff):

enum MyType{
   Saw, Saw2, Saw3, mt_end
};
const char* pMyType[] = { "saw", "saw2", "saw3" };

Now, you can use MyType as an index into the array pMyType. Assume the use input the name "saw2", then you could use something like this to determine which enum they referred to:

MyType findType(const char* user_input)
{
    for (MyType t = Saw; t != mt_end; t++)
    {
        if (pMyType[(int)t] == user_input)
        {
            return t;
        }
    }
    return mt_end;
}

This works because enums are either char or int types (depending upon what is something for your to look up). Just remember, you cannot assign an integer value to an enum without casting it to the enum type. Ie, this is wrong:

int i = 2; // 2 == saw3
MyType t = i; // Compiler error!

but this is not:

int i == 2; // 2 == saw3
MyType t = (MyType)i; // Ok, cast works, as long as 'i' associates with a member of MyType

Clear as mud, right! :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Please, just post the code inside code blocks, as in

// This is C++ code

Asking us to download data and then analyze it is inconvenient at best, and a vector for malware at worst. :-(

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Get a start on this, and then maybe we can help you. Don't ask us to solve your class problems for you! :-(

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Memory mapped files: this allows you to write to a physical on-disc file as though you were writing to memory. Ie, the file is "mapped" to a memory location. Let's say you want to change the data 100 bytes into the file, replacing the contents with "hello world". Ok, assume the file is mapped to the pointer:

char* pMappedFile;

Once that is done (won't get into details how to do that here - this is theory!), you can do this:

const char* hello = "hello world";
strncpy(&pMappedFile[100], hello, strlen(hello));

Whatever was at that location in the file, on disc, has now been changed to "hello world".

So, the idea is that in some instances, this can significantly simplify your code as you don't need to concern yourself with seek()/write() and other file operations. You just treat the file as a chunk of program data memory.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Simply enough, your code:

typedef Car Element;

is invalid since Element is already a defined type. What you are saying is that Car is Element. Is that what you really mean? Please clarify what you REALLY mean here.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

A polymorphic function:

class SomeClass {
public:

int doSomething(void);

int doSomeThing(int);

int doSomething(AClass&);
};

The member function doSomething(...) has three signatures in this instance, each with a different argument list. This is an example of polymorphic behavior where the type of thing (or things) you pass to the function determines which one gets the call. So, a class Animal may have a polymorphic function likes(). One may be likes(Cats), or likes(Dogs), or likes(Dinosaurs)... Clear as mud yet? :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

1. Until you write a sane value to an address, it is uninitialized, and contains random data.
2. Ditto.

You can allocate memory, it has an address, but until you store something there, it contains garbage.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Here is a link to the driver support site for HP and this printer in particular. Note that they do NOT support network printing for this model! Sorry, but I think you are stuck being tethered with a USB cable. However, you could plug in a wireless linux device the size of a pack of cigarettes that can connect to the printer via USB, giving your "wireless" connectivity (network printing) from anywhere in the area. In fact, HP has some such wireless print servers - used them in the past myself. Anyway, here is a link to the support page: http://hplipopensource.com/hplip-web/models/photosmart/photosmart_c4500_series.html

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Assuming the motherboard has most of the same features/capabilities as the old one does, and you are reinstalling the original system discs, then probably not. Video chip sets may be the biggest issue. If that changed significantly, then you may need to boot from a rescue CD/DVD and change the video driver settings in /etc/X11/xorg.conf.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

There may be such software, but I don't know what it is. You would need some software on the phone to make it act like a USB webcam for the computer OS, and depending what device it emulates, you may or may not need to install driver software on the computer. Myself, I just get a small USB webcam that works with my laptop on Ubuntu, and go with that.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

When I have to do something like this, I take my smartphone (Google Nexus One) along with me, plug it in to the other machine (called tethering), Ubuntu recognizes it as a broadband modem and connects instantly to the internet, then I can install all this stuff from the repositories, including downloading and installing the dependencies automatically. If you don't have that, take it to a local WiFi hot spot and do the installation there.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Whether or not you can send an email to a phone and have it delivered as an SMS message would, I think, depend upon the carrier and the options the user has on their account. It is possible that they don't have SMS at all. I know that I don't on my AT&T phone account. Don't want it, don't need it. Since I have a smart phone, email works just fine for my purposes.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

It has to do with the associations of application and file extensions. If you right click on the .exe file, open properties, and then click on the tool icon, you will get a form that shows what applications are associated with that extension. You can change, or move them up/down to change the default. So, the system thinks .exe is another name for .zip... :-). A Windows exe file may run in the Wine environment, but you need to make sure you have Wine installed. Then you may be able to run it as an application in Linux.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I have Deitel's book "How to Progeram C++" by Deitel & Deitel, and while it covers a lot of stuff quite well, following it point-by-point may not be the best way to learn the subject. Personally, I read it about 10 years ago (3rd edition, 2001) after I had spent 10 years programming major systems using C++, and thought to myself, yawn... I just pulled it off of my bookshelf (100 linear feet of programming and computer software books), and looked again. There are issues, so I'm not sure I'd recommend it as a self-teaching tool all by itself. If you are interested in what those issues are, let me know and I will get into some detail. Right now, I need to get back to cooking dinner for out-of-town friends that are coming to give a house concert tonight.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Quick translation: &name means "take the address of 'name', so if you have an integer variable named anInt, &anInt returns the address (pointer to) the 'anInt' variable. As a result, this:

int anInt = 999;
int* pToInt = &anInt;
printf("anInt == %d\n", anInt);

and this

int anInt = 999;
int* pToInt = &anInt;
printf("anInt == %d\n", *pToInt);

will both print this:

anInt == 999

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Note that the wait(int) function is user-defined in this example rather than supplied by time.h.

Not necessarily a good approach. This will suck up a huge amount of cpu, a tight loop making a system call like this. In effect, the sleep(n) or Sleep(n) function does a kernel call to set an interval timer and wakes up when the time expires. Because this is handled in the kernel idle loop, without recourse to a user loop, it effectively takes no CPU time at all.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Post your compiler error messages here, along with your current code.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

No you haven't. Windows uses Sleep() not sleep() (capital S). Also, *nix sleep() parameter is in seconds -- MS-Windows Sleep() parameter is milliseconds.

Ok. It was a long time ago (10+ years), so I probably put an #ifdef in a header to convert sleep(n) to Sleep(n) when it was compiling on a Windows system. This was code that ran on Unix systems as well as Windows, and there was a lot of that sort of cruft to get common code to build on Windows. When it comes to programming standards, there is the POSIX world, and then there is Microsoft's world - ne'er the twain shall meet!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

there are no standards for waiting. *nix, MS-Windows and MS-DOS all use something else. The c++ standards say nothing at all about the topic.

Ok, *nix standards use sleep(n). I've also used that with Windoze.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Mike, you are giving away the recipe for the secret sauce! :-) Anyway, well stated!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Change case to upper: toupper(int c) - loop through the string and apply this to each character.

Change case to lower: tolower(int c) - ditto

Reverse case: if isupper(int c) tolower(c), if islower(c) toupper(c)

You figure out the details.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Standards use the sleep(seconds) function, not wait.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

1. Pointers are of a size to match the word size of the processor and operating system. A 32-bit OS will have 32-bit (4 byte) pointers, and a 64-bit OS will have 64-bit (8 byte) pointers. In the "old days" DEC 10 and 20 systems had 36 bit addresses some supercomputers (wavetracer, etc) had 128-bit addresses, and a lot of micro-computers had 8 or 16-bit addresses.. These days, it is either 32-bit or 64-bit for the most part.

2. Think of a pointer as in "points to content". So, an int* pointer will point to the location in memory of an integer.

3. In the first instance, since the pointer was not initialized with a valid value, it was pointing to random data. Meaningless, unless you try to access it, in which case your program will crash. In the second case, where it is initialized to an array, a pointer may point to a single value, or an array of values. In this case, the addresses are sane/valid and "point to" the actual data. This is a Caveat Programmer issues, since a pointer to data may be a single value, or an array of values. Make sure you know which!

4. When you assign an array to a pointer, it only is valid for members of the array. Anything beyond the end of the array is either pointing to something else, or is random data. Caveat Programmer! is still in force here.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

At this point I have to ask why install redhat then use CentOS repos? Why not just install CentOS?

If it is a clean install, then go for CentOS. However, a lot of acknowledgeable people know the name Red Hat, and nothing about its free clones like CentOS or Scientific Linux, so they purchase or evaluate RHEL, decide they like the product, but not the ongoing support costs. So, they are then in limbo - it isn't obvious how to switch from RHEL to a free version, even though it is in effect quite easy. A lot of the time they are uncomfortable with command line interfaces, which is necessary to use to switch the yum repositories.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Sure we're here to help.. :icon_evil:

  1. If you're using a decent web browser, this is how you find out what is b* tree:
  2. Left click (and hold) just before "what"
  3. Now drag your mouse to the right until you have selected the "is" and "b*" and "tree" as well.
  4. Leave the left button.
  5. Now right click in the middle of the selected text.
  6. In the menu that you see, look for the word Google or Yahoo or Search and click on it.
  7. A new web-page should open up with answers !!
    PS: Of course you'll have to read it.

Amazing isn't it?!

PS:
1. This amazing method is known as RTFW.
2. In case you're not using a "decent browser" then get back and I would tell you an alternate way.

Or do the same thing with "what is avl tree"... :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

In Linux/Unix systems, a dll is called a shared library, and has a .so extension. Read the g++ and linker documentation (man pages) how to do this. It is quite simple to create a shared library with Linux. In any case, the compiler directive when creating the library is -shared. If you are creating a shared library from object (.o) files, then make sure you compile the object files with the -fPIC option. That generates what we call Position Independent Code (PIC), which is necessary for a shared library, since the functions may need to be relocated (different memory position) when they are loaded into the executable.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

This isn't a C++ question. It is a question about a specific library/API for video capture. Look at the error. It indicates that it cannot connect. With what? The camera? The video stream? Don't assume people here are experts in a specific API. Questions should be restrained to C++ programming issues, in my opinion.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Thanks for the quick responses.

I really appreciate it.

@Narue: I've never written a change making program. I didn't find any reference of that in my textbook. What should I look under?

@rubberman: No EC for you, but you've my gratitude? lol The most useless and undesirable prize I'd say. lol sorry.

No problem. I like to get folks to think about their problems, as a first step toward solving them. Understanding the scope is essential in that. As a teacher, sometimes I have to get in my students' faces. We all like to take the easy way out, but that doesn't help us elevate our skills.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

The << and >> operator do have higher precedence than the bitand & operator, see this table.

However, I would not recommend that you rely on operator precedence in that kind of fashion. If you need, absolutely need, to use a #define, then wrap everything with parentheses and avoid the problem:

#define FLAG_FAST         (1 << 0)
#define FLAG_VISIBILE     (1 << 1)
#define FLAG_BIG          (1 << 2)

In this case, however, you are defining those flags in a very impractical fashion. This is the more "usual" way, using hexadecimal numbers:

#define FLAG_FAST         0x00
#define FLAG_VISIBILE     0x01
#define FLAG_BIG          0x02
#define FLAG_FOO          0x04
#define FLAT_BAR          0x08
//...

But when I say that the above is "usual", I really mean that it is commonly found in C libraries or APIs, but not in C++ code. In C++, there are several alternatives that are safer and better. One is to use a const global variable (or static const data member of a class):

const unsigned int FLAG_FAST     = 0x00;
const unsigned int FLAG_VISIBILE = 0x01;
const unsigned int FLAG_BIG      = 0x02;

Another popular solution is to use an enum:

enum MyFlags {
  FLAG_FAST     = 0x00,
  FLAG_VISIBILE = 0x01,
  FLAG_BIG      = 0x02
};

And usually, the enums are nested in the class or namespace they are used in or for.

MACROs in C++ have their place for very special purposes that cannot be achieved by any other means and do require a simple text-replace preprocessing. But defining constants is definitely not part of the circumstances in which …

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Still of topic as question was asked why it is running slower on Windows. Down voting my re-primal that you are going off topic is just lame...

Lame, I agree, and apologize for my pique. Won't happen again, but you could cut folks a bit of slack in these regards. Just my 2cents worth.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Mostly, operator precedence is defined by the language standards, but precedence between operators of equal precedence is up to the compiler implementor. That's why I said "Caveat Programmer!" - define your macros as you intend them to be evaluated, scoping them accordingly. Otherwise, what works on one system or with one compiler, may not on another, or even the same platform and compiler after an update.

Another example of this situation is when arguments that are effectively function calls (including prefix/postfix increment/decrement operations) passed to a function have side effects. Since the order of evaluation of the arguments to a function are also implementor-defined, these side effects may cause the function to get arguments of values that are different that what you expect. Again, Caveat Programmer!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Than's for the advice, I'm off to bed bet right now, just got up to post a news flash about Libya that I got from my phone, then saw your response. I'll definitely check this out in the morning though. Thank you very much:)

Sorry, accidentally down-checked this post - unfortunately, once you do that I don't know of a way to undo it... my bad!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

@rubberman better read properly before you reply.

@1ML no idea why emulator is running so slow for you I have no problem on my pc (dual boot win 7 / ubuntu 10.10). However I do use IntelliJ instead of Eclipse. PS: You sure that partition was deleted? Windows normally moves boot-loader to it self, but it wouldn't wipe existing partition unless you told it to do. To recover boot-loader check this document

I was replying to the post immediately before my last one, so in that sense I think it was on topic, if not specific to the original posting of this thread.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Actually, in C the pointer analogy is correct. However, in C++, it actually is passed as a reference to the array. Functionally the same, semantically subtlety different. In any case. The nice thing about references is that you don't need to verify that the passed pointer is not null... the compiler deals with that for you mostly, and when it doesn't, runtime exceptions allow you to "catch" such problems much more easily. So, do get into the habit of (judiciously) using exception handling in your code. Too much is counter productive. Too little leads to system crashes. Just enough allows you to intelligently recover from may errors, or terminate the program in a much more controlled manner than a simple core dump.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Following your statements, neural network and fuzzy logic are examples of IR in programming systems today. Have you studied those disciplines? They are both founded upon rigorous, and proven, mathematics and logic. How familiar are you with Prolog, Lisp, CLIPS and other such inductive reasoning languages and tools? This is not new stuff you are talking about, and many use these tools to great effect in solving otherwise intractable problems. I have applied such methods myself to the development of adaptive systems that currently manage the manufacturing processes at most semiconductor fabs in the world...

So, I don't disagree with what you are saying, but I AM saying that this isn't necessarily new nor innovative. You've rediscovered fire! So, agreeing with you further about the ability of such techniques to reduce system complexity, here is an example:

A thousand lines of complex, but well-written C++ code --> 1 line, and 6 rules written by manufacturing engineers (not software engineers or programmers) stored in the database. That was the delta to associate a lot (carrier of wafers) with the next bit of equipment in a semiconductor fab that is the best choice to process the lot on its next step in the process plan. Some of the factors involved with that decision would be alternate steps in the process plan, current recipes loaded in the equipment needed for those steps, priority of the lot compared with other lots ready to process on that equipment, the maintenance state (or planned …