Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Could someone help me to understand more on class objects and help me on this code

Sure, what exactly do you want help on? The functions fadd(), fsub(), fmul() and fdiv() all take parameters but you failed to include them in the class declaration.

In the class function implementation code you did not specify the class, for example

float calculate::fadd(float a, float b, float c, float d)
{
return (a*d + b*c)/(b*d);
};

also what happends when (b*d) is zero? The function above will cause a divide by zero exception. Here is a better way of handling that

float calculate::fadd(float a, float b, float c, float d)
{
      float denominator = b * d;
      if( demoniator != 0)
          return (a*d + b*c)/denominator;
      else
         return 0;
};

or like this using exception handling try/catch block

float calculate::fadd(float a, float b, float c, float d)
{
      float value = 0;
      try
      {
          value = (a*d + b*c) / (b * d);
       }
       catch(...)
       {
            // oops! divide by zero error
        }
        return value;
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

so i would use out<<mystring<<endl?

Yes. Suggestion: write yourself a small test program that does nothing more than open a binary file for output, write some data to it, close the file, then open a binary file for input and read the data back in. That will teach you how binary files behave.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>izzit my compiler problem? Borland C++ 5.02????

Not very likely -- the problem is in your code. But if you don't want to post it then there isn't much anyone here can do for you. You can zip up the project (minus compiler-generated files) and attach to your post.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

strings are written to binary files exactly like they are to text files including the '\n' at the end to identify the end of the string.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

use ofstream's write() method to write out each individual object, for example

ofstream out("filename");
out.write((char*)&a,sizeof(int));
out.write((char*)&b,sizeof(int));
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

post the code that does not work. After closing the file you should call the clear() method before attempting to open another file with the same fstream object.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you got a core dump use debugger to find out where the seg fault occurred. Its probably somewjhere else if your program. No body can tell unless you post the rest of your program.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

same problems as before -- you have used the same name for functions and variables. You can not do that.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Jobra: you have to change. Please repost your code.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Sorry, I can't access that link you posted, not because its a bad link but I'm blocked out of accessing it. If its a large source file them you would be better zipping it up and attaching it to your post. If its rather small then just post it using code tags.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you google for directx example programs you will find lots help

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

They are nearly different languages, so you should do one or the other, but not both until you have a good grasp of one and can recognize the differences.

I'd go for VC .NET and ignore VB 6 for a couple years. If you are planning to get a job as a VB programmer then you will need both because there is a lot of VB6 code that you will probably have to maintain.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

How does that relate to computer software or hardware????

You will probably find the answer in your textbook.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

None of this will explain the OP's problem because he has not yet posted the errors he was getting -- the errors could be something completly unrelated. His original function should work because vectors do not require pointers -- we use vectors of c++ classes all the time, for example vector<string>. . One possible explaination for the OP's problem is that his class may not contain an explicit copy constructor. But that too is just guesswork since he did not post the declaration of the class.

We definitely need more information from the OP before we can suggest ways to correct his problem(s)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Lazaro: you are causing huge memory leaks doing it that way. When are you going to delete those pointers? answer: never because they are overwritten with new values in each loop iteration. The parameter to your push_back is not saving the pointer but making a copy of the class just as in the OPs code. The pointer itself is discarded.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what errors do you get? Does SampleMarketDataClient class have a constructor that takes a string as an argument (assuming lineString is type std::string)?

Lazaro Claiborn commented: He's a good poster. +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes -- you can get free source code here. I don't know if it works or no because I have not seen it.

You might get more code from google links

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

why don't you just contact their support people? You will get a quicker and more accurate answer that way.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

use the mod operator -- it returns the remainder after division. If the remainder is 0 then the number if evenly divisible by the value

When (loop_counter % 100) == 0 then close the current file and start another one.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

To convert a single character to an int just simply subtract '0' from its ascii value

char c = '1';
int num = c - '0';

When converting several characters to int you have to multiply the previous value by 10 to make room for the new digit.
Below num is an integer and digits is a character array that contains all the digits. This code snipped would be placed inside a loop.

num = (num * 10) + digits[i] - '0';
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

check the files in the project director with Windows Explorer -- that inData file is not where you think it is.

Second problem: the individual cases in the while statements need to end with break statements, otherwise without it the code will just keep executing all the cases below it.

Third: how do you expect that while loop to terminate? Isn't it supposed to process each line of the inData.txt file? Should be coded like this:

while( infile >> xactCode >> xactAmt )
{
  // blaba
}

[edit] Ok, I was typing while you were posting corrected information. Since you've already fixed it just ignore my comments above. [/edit]

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>By the way the point of the HW are classes

Well, so much for your teacher's reputation, it just went into the gutter :eek: But we should be discussing your HW, not your teacher.

Had you left the pointers there it would have made your program just a small tad more complex but a whole lot safer because you could have allocated memory of the correct size for the strings, something like this:

PCourant->nom = new char[line.size()+1];
 strcpy (PCourant->nom, line.c_str());

Don't forget to delete[] to memory when done with it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Sorry but I didn't get what's wrong with "if( FIVE_AM <= seconds_elapsed_today <= SIX_AM )" ?

Illegal syntax -- here is the correction if( FIXE_AM <= seconds_elapsed_today && seconds_elapsed_today <= SIX_AM) or if( seconds_elapsed_today >= FIXE_AM && seconds_elapsed_today <= SIX_AM)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>so now i give to the other function{funcA} a simple integer that contains only a number from 0 to 23....

that is not a time_t variables that is initialized from time() function. If all you are going to do is pass an integer between 0 and 23 then the check is trivial.

bool foo(int hourl)
{
   if( hour >= 5 && hour <= 5)
       return true;
   return false;
}

>>PS can anyone explain this line
The mod operator returns the remainder after division. In this case it will return the number of seconds that has passed since midnight. The time() function returns the number of seconds since 1 Jan 1970 (I think that's the date). There are 86,400 seconds in a 24 hour day and the remainder of any number divided by 86400 is the number of seconds in the current day.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>I just checked with Firefox's RSS reader, and everything works as expected
Being new to RSS Feeds I don't know what that means.

If you click the RSS Feeds it says Yesterday, February 18, 2007, 6:11:26 PM which was 13 hours ago.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

@Ancient Dragon => That is the right way of doing it. Declare your callback function to take the this pointer. Same mechanism used for thread functions as well..

If you are writing your own interface then you may be able to use non-static class methods for callback functions. I've see this coded a couple times but don't recall exactly how its done. The problem is when you have to pass callback functions to a function that you did not write, such as win32 api and other library functions.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>if( FIVE_AM <= seconds_elapsed_today <= SIX_AM )
If you want to post code, please at least post valid code.

>>time_t seconds_elapsed_today = epoch_time % NUM_SEC_IN_A_DAY ;
Good idea :) , which I had thought of that too.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Seems to me the concept here is to learn to process c-strings, because they are necessary in C++.

earlyriser, stop using any and all functions that have a definition of string and use only char* functions. Help us save Joe's sanity. :)

He's already said his instructor says he must use char arrays. He should be writing a pure C program, not a C++ program basterdised with C. If that is what his instructor is teaching then the instructor needs to take a few more programming courses.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I have. They do: CHAR_BIT

No Dave, thats a macro, actual value of that macro is defined by the compiler.

.I'll stick with the C and C++ definitions. 'Cuz I've been bitten where it can bite.

Agree. When a program must know the number of bits in a byte then use the CHAR_BIT macro.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

both of the answers don't solve my problem because basically what i wanted to do is pass the current time {in time_t format} in a function, that will check {among other things} if the time is between 5 and 6 am....

you must not have comprehended what we posted because the suggestions will do just what you want.

int foo(time_t time_to_check)
{
    struct tm *tm = localtime(time_to_check);
    const time_t five_am = 18000;
    const time_t six_am = 21600;
    // convert current time into seconds since midnight
    time_t now = ( (tm->tm_hour-1) * 60 * 60) 
                         + ((tm->tm_min-1) * 60)
                         + tm_tm_sec;
   if( now >= five_am && now <= six_am)
   {

          cout << "Great time";
   }

}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I joined the feeds today using newly installed Vista Home Premium. When I hover the mouse over the DaniWeb feeds link in IE7 it says it was last updated 4 hours ago with 0 new feeds. When I visit c/c++ board I see several new posts during the last 4 to 8 hours.

How do those feeds get updated? They don't seem to be very current.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

But I guess that would beat the purpose of designing class for creating objects since each object created would have the same thing inside of it (the member variables being static).

Yes it would -- but in some cases I can think of there is only a single instance of the class anyway and making everything static would only be useful in such a case.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Rejected by McDonald's :eek: Did they tell you the reason? Do you look like someone that just crawled out from under a rock ? Drug user? Alcholic ? (those are all rhetorical questions that don't need an answer) . Maybe you need to get employment counseling to learn how to dress and act during employment interviews. Employers will not hire anyone who looks and smells like they just vomited all over themselves.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

if you search these threads you will find several threads on this topic.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> in visual c++ in windows
yes, its called the win32 api. There is also MFC library supported by Microsoft compilers as well as C# language that make windows gui programming a little easier.

There is also a PDCurses that is a port of unix curses for MS-DOS and MS-Windows console programs.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you can not upgrade from xp home to xp business -- see the last post in this thread.

Your computer's speed is adequate, but I think you need to add more RAM. And you should replace those two small hard drives with one larger one -- I bought a 350 gig drive here in USA for about $100 USD.

If you have the money to blow then you will probably be better off just buying a new pc with vista pre-installed. Give you current pc to a relative kid or donate it to your favorite charity and get tax writeoff.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

To my knowledge there is no standard way of remapping the keyboard keys except by changing the keyboard language (English, German, Spanish etc). But if you are a C or C++ programmer you could write a program that would hook into the keyboard device driver and make that change.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I didn't know that C is better for char arrays than C++.

That's not true, character arrays can be handled equally by either language.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

5:00 am is (60*60*5) (60 seconds in an minute times 60 minutes in an hour) = 18000 seconds after midnight. 6:00 am is (60*60*6) = 21600 seconds. After getting local time, convert the hour, minutes and seconds to an integer ((hour-1) * 60 + (minute-1) * 60 + seconds), then check if it is between 18,000 and 21,600.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

One way to get a static member access non-static methods is thru a static or global pionter or reference to the desired instance. Then the static member uses that pointer to access non-static methods and data objects.

Another method is to make static all the methods and objects that the static method needs to access.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is some information. For more info you can google for your question. Writing a dll is just too complicated to fully explain here. Read some of the google links.

How to interface a DLL with python is probably best to post in the phthon board.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

why would you even want to do that? just press the standard shift key.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> strcpy (PCourant->nom, line);

line is a c++ class, strcpy() wants a c style pointer. You have to use std::string's c_str method to get the pointer, like this strcpy (PCourant->nom, line.c_str());

struct Professeur
{
    char nom [20];
    Professeur *suivant;
};

Since you are writing a c++ program you should use c++ std::string class, not character arrays, unless your teacher requires you to use character arrays. Using std::string will make your life a lot easier and eleminate several problems with using strcpy() and other similar standard c string handling functions. The main problem with those functions is they will allow you to scribble all over memory by copying strings beyond the allocation of the destination buffer. Example: copy a 25 character string into that buffer that has only room for 19 characters plus null terminator. After that happens your program will likely crash at some point and you will spend hours trying to find the problem.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Thanks to this thread I found out why Notepad was unable to save an existing text file. I kept getting errors that it could not save the file even though I read the messages carefully and answeres Yes to them all. After reading this thread I went to control panel and turned User Account Control off. Now I no longer get those annoying messages and Notepad saves the file(s) ok without error. :) :) :) :) :) :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I just finished installing Vista Home Premium -- my score is 4.2. I suppose that is adequate.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Perfect description :cheesy:

It looks like some white stuff from an animal! I don't care how many health benefits it has; I'd rather have a cold than have to eat that horrid white cold goop.

The plain, white unflavored yogurt is not normally eaten by itself -- it tates awful. The kind with fruit in it is really good to eat by itself -- mix it well before eating.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I have had XP Pro for some time and just today installed Vista Home Premium. It would not allow me to upgrade XP Pro because it said I would need the Business or better version. So it did a fresh install on a second drive d: in my computer and created the dual boot option automatically. Now I can boot from either os :)

Unfortunately it would not copy the installation files from XP to Vista so I will have to reinstall everything myself.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Files transferred to MS-Windows from *nix will also have that problem unless the file is run through a translation program. Most FTP programs can correctly translate the file during file transfer operation.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

close: When result is 0 the equation reduces to -b/2a because the square root of 0 is 0.

if (x == 0)
    {
        result1 = -b / (2 * a);
        cout << "Two repeated roots of:  " << result1 << endl;
    }