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

There are many ways to implement it, here is just one of them.

If you want to store information in the registry instead of ini files then here is a good c++ class, although there are many others.

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

Your last statement is how its normally done. Create one object then call all its methods as necessary. If you declare the methods static then you don't have to create an instance of the object in order to call the function

class A
{
public:
   static int getBeta();
};

int main()
{
    A::getBeta();
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Must be your browser -- it looks normal to me.

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

I don't get that problem with either IE7 (64-bit version) or FireFox version 3.0.3

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

Compilers are free to choose to ignore the inline keyword or not.

Move the code in test2.cpp to test2.h since you use the linline keyword, then delete test2.cpp from the project.

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

>>The only thing I can figure is that it starts counting at 1 instead of 0 a
No, arrays are always numberd beginning with 0. The a+5 in line 9 that you posted is 1 element beyond the end of the array, which satisfies the end statement that you posted. So it will fill array element numbers 0, 1, 2, 3, and 4 but not 5.

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

1) delete all those unreferenced variables. They just clutter up your code and compiler err/warning messages.


2) after completing 1) then you can see the real errors. One of them is that you used ( when you should have used { in the opening function brace. The other is that function quit is not declared correctly.

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

Those symbols are in different fonts, which require a GUI program such as M$ Word or your browser to display them. Can't use them in normal console programs.

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

You can find out what namespace it is by reading the header file in which it is declared or reading the programmer's documentation (for example looking it up in MSDN if it is a win32 api function).

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

resolved with the using clause, such as using namespace std; . Alternatively you can just put the namespace when you declare the object, such as std::string mystring; or mynamespace::myobj obj;

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

If you only want something done on Saturday (when dow == 6) then write a bit of code that will call Sleep() and put your program asleep for 24 hours, then check again. Make sure the program waiks up again at midnight so that the next checks will work.

Once the day is 6 keep checking once a minute until the hour is 0 and minute is 14.

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

I don't think it would work here because it would not have enough traffic to make it viable. DaniWeb is devoted to IT related issues. I'm sure you can find other suitable web sites for help with electrical engineering.

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

>> ptrBase->member3
That doesn't work because base class knows nothing about the inherited classes. It has to be typecase to the desired class

int main(void) {
	Base ob1;
	Derived ob2;
	Base *ptrBase;
	ob2.member3 = 1;
	ptrBase = &ob2; // works fine
	cout << endl << reinterpret_cast<Derived*>(ptrBase)->member3 << endl;
	cin.get();
	return EXIT_SUCCESS;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

A static class variable is like an ordinary global variable but has scope only within the class. Like global variables, there is only one instance of a static variable regardless of the number of instances of the class.

>> it complains about missing Count in DLListNode class...
Because you also have to declare it just like a global variable, but with class scope. Here is a simple example.

#include<iostream>
using namespace std;

class MyClass
{
public:
    MyClass() {x++;}
    ~MyClass() {x--;}
    static int x;
};

int MyClass::x = 0; // <<<<< declare class static variable

int main()
{
    MyClass a;
    cout << a.x << "\n";
    MyClass b;
    cout <<  b.x << "\n";

}
mrboolf commented: Really helpful and straight to the point. Thank you :) +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 42: since the array temp was not initialized, calling strlen() will produce unpredictable and unreliable results. You don't want strlen() of temp but sizeof(temp) so that it can be used in lines 45 and 46.

You can replace lines 42-47 with just one line char temp[251] = {0};

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

The way I understand it is all you have to do is create the functions you mentioned then move the code from the switch statement into the appropriate function, finally add function call inside the switch statement. Don't worry about menus etc until you get the hang of writing functions. Just make the changes one function at a time to keep you from getting confused and overwhelmed. Example:

void AreaCircle()
{
    cout << "Enter the radius of the circle: "; 
    cin >> radius;
		
    if (radius < 0)
    {
        cout << "Number must be greater than 0. Try again" << endl;
    }
    else 
    {
       circleArea = PI * pow(radius, 2);
       cout << "The area of the circle is: " << circleArea;
   }

    cout << endl;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

try this:

while (peopleCount < FINALPOP)
	{
		 annualGrowth = annualPerc * INITPOP;
		 peopleCount += (int)annualGrowth; // + INITPOP;
		 yearsLeft = FINALPOP / (float)peopleCount;
		 // peopleCount += peopleCount;
		 cout << peopleCount << yearsLeft << endl;
	}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

instead of system(pause>nul) why didn't you just simply use cin.get() ? you wouldn't have to have done all that net searching :)

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

Sorry, I'll have to get to this tomorrow evening if someone else has not answered your questions by then.

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

The instructions you originally posted are very confusing. Is that the exact wording of the assignment, or just how you interpreted it. Please post exact assignment.

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

In Dev-C++ IDE, go to menu Tools --> Compiler Options. then in each of the tabs make sure that it shows the full path to evrything. Such as Binaries: c:\dev-cpp\bin. There are some instructions on bloodshed.net's forums that says Dev-C++ has some problems on Vista and that's the way to fix them. Worked for me :)

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

I got that same output with the code you posted.

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

Oh yes I see it now -- I had to press Tab to get to the screen with the grid. After clicking several times it finally failed.

I think I found it. Its writing beyojnd the bounds of arrays. You are allocating too few POINT3D structures.

void DrawMap(HDC hDC, int ScaleWidth, int ScaleHeight, int XOff, int YOff)
{
	POINT nullPT;

	if(plgonsize >= 3)
		{
		p3d = new POINT3D[plgonsize];// - 1];
		new_plgon = new POINT[plgonsize];// -1];

		for(int p = 0; p < plgonsize; p++)
		{
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't see a grid on the screen, and clicking on the screen does nothing.

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

funny that the code works ok for me. Are you certain we have the same code ?

memory leak here -- you need to delete the pen after creating it.

case 0://DRAW PERSPECTIVE
			DrawMap(hDC, ps.rcPaint.right, ps.rcPaint.bottom, ps.rcPaint.right / 2, ps.rcPaint.bottom / 2);
			hPen = CreatePen(PS_SOLID,5,RGB(255, 0, 0));
			SelectObject(hDC, hPen);
			TextOut(hDC, 0, 15, "[A: move left] [D: move right] [W: move forward] [S: move backward]", 67);
			TextOut(hDC, 0, 30, "[UP: move up] [DOWN: move down]", 31);
			break;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

more than likely yes, but I'd have to see the code for a difinitive answer. What os are you using because Dev-C++ has worked for me on every recent version including Vista.

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

maybe yes, and maybe no. Depends on the code and what compiler it was written with. If written with Turbo C then probably won't work with VC++.

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

If you wrote that then you should know why. You should also reformat the code to make it easier to read and understand. Example below:

#include <iostream>
#include <string>
using namespace std;
int main()
{
    string softserve, topping, sprinkles;
    string order;
    do
    {
         if (softserve == "")
              cout << "Do you want chocolate, vanilla or twist?\n";  // endl not needed here
        if (topping == "")
<snip>
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Your program seems to be too complex.

int main()
{
  FILE *pS, *pD, *pT;
  int a, n=0;
  int[/color  c=0;
  char *dabuff;

  pS = fopen("INVITACION.TXT","rb");
  pD = fopen("BACKWARDS.TXT","wt");
//
// no need to use sizeof(char) because its guarenteed to be 1 by the standards
//
  fseek(pS,-1,SEEK_END);
  while( ftell(pS) > 0)
  {
     c = fgetc(pS);
     if( c != '\r' ) // you don't need this for *nix or MAC
         fputc(c,pD);
     fseek(pS,-2,SEEK_CUR); 
  }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Its not necessary to initialize std::strings with blanks because that is the default. Just declare them like this: std::string softserve, topping, sprinkles; I think your program needs more cin statements for data entry.

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

You can do it any way you want. You don't even have to nest the two functions like I showed you.

int n = function2(number.one, number.two);
cout << function1( n, number.two);

There are lots of ways to do what you described. Let your imagenation be your guide and try them out with your compiler to see what happens. Practice makes perfect :)

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

First, open the file in binary mode so that the os doesn't interpret the '\n' characters. Then you have to call seek() after each read operation.

What you do with '\n' depends on what operating system you are using. *nix files just have '\n', but MS-Windolws uses '\r' and '\n', and MAC uses just '\r'.

int chr;
ifstream in("filename", ios::binary);
in.seekp(-1, ios::end); // see one byte from the end
do  {
    chr = in.get();
    in.seekp(-2, ios::cur);
} while( in.tellg() > 0); // while not at beginning of file
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

After making the above changes the dot still doesn't move because you neved added code to move it.

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

I uncommented the code but didn't crash and didn't actually do anything, meaning the dot didn't move when I pressed any of the keys. Probably because the case statements are wrong, for example the letter 'A' is 65, not 61. You need to look at any ascii chart. you might also want to accept either 'A' or 'a'. And the easiest way to do it is like this:

case WM_CHAR:
            switch (wParam)
            {
                case 'A': //a
                case 'a':
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

To change UNICODE setting: Select menu Project --> Properties (at the bottom of the menu), expand Configuration Properties, select General, then in the right-hand pane change Character Set to Not Set

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

Here is one way it could be done.

class example
{
public:
   int one;
   int two;
};

int function1(int one, int two)
{
   return one * two;
}

int function2(int one, int two)
{
    return one + two;
}

int main()
{
    example number;

    cout<<"enter numbers"<<endl;
    cin>>number.one>>number.two;   
    cout << function1( function2(number.one, number.two), 3);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I'm running on 64-bit Vista Home Premium, used VC++ 2008 Express, and your program ran ok for me both in IDE and command-line. After creating a win32 windows project I used all default values except changed from UNICODE to non-UNICODE.

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

you can ask ten programmers to write the same program to the same specification and get ten completely different solutions.

But only one correct solution -- mine :)

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

Your program works fine for me.

Sci: His last post was only main() -- the rest is in the origianl post.

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

1) after line 19

2) Change line 28 to test for return value of line 26

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

I guess you mean you want to know about the best compiler. On Vista that would be Visual C++ 2000 (Express). There are other compilers but IMO M$ VC++ 2008 Express is the best, mainly due to its excellent debugging facilities. Most any modern c++ compiler will compile c++ code ok, but trying to fix your mistakes can be very frustrating on most compilers.

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

line 20 is in the wrong place -- move it down to line 25, when the variable search_item is known.\

[edit]^^^ he beat me to it :) [/edit]

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

The error on line 23 says variable i has not been declared. The reason is that you have to use { and } braces in the loop starting at line 19.

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

First you have to allocate memory for ebase -- you are dereferencing an unallocated pointer. So the best you can do with that is ebase = *iter;

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

>>and if not, repeat. Then display the list.
Displaying the list is not a requirement as the OP posted.

You could use an array, but its not necessary because there is no need to keep all the input values. Just sum them up as they are entered. You also need another counter to keep count of the number of entries the user entered. After all done, then just do the simple math.

This is really a very simple program that requires no (zero) advanced things such as <vector>, arrays or memory allocations. Don't make this more difficult than is needed.

VernonDozier commented: Good observation. +8
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I thought you said you know the basics. But apparently you don't.

int main()
{
   float mean = 0;
   float range = 0;
   float num = 0;
   float sum = 0;
   int NumberInputs = 0;
   // infinite loop
   for(;;)
   {


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

>>I am at a university.

Quit. Go to some other university because that one obviously will teach you nothing.

Do you know what the mean is and how to calculate it? How about the range? If not, then google for those terms.

And like I said before, take it one small step at a time. As someone once said "use the Divde And Conquor" method to solve the problem.

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

>>There is no textbook.
What the hell :-O Are you doing this in some sort of school ? or learning c++ all on your own? I assumed you were in school, but maybe I was wrong.


What part(s) of the assignment don't you know how to do. cin or cout , or something else

I'm sorry, but we can't give you a complete course in c++. If you are on your own then I'd strongly suggest you spend some $$$ and buy a good c++ book that will teach you.

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

"to prompt" just smply means use cout to display the message cout << "Enter something\n"; and to get input for a string. You need to STUDY YOUR TEXTBOOK for other variations of cin and cout.

std::string myname;
cout << "Enter your name\n";
getline(cin, myname);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Start here

#include <iostream>
using namespace std;

int main()
{
   // put your code here

}

Re-read my previous post #2 and code one sentence at a time. Code the line that displays the prompt. Get that to work and compile, then code another line that asks for user input.

Have you read your textbook and done the example programs at the end of each chapter? If not, then you should do that.