Describe usage of const in C++?
84903
In C++, const is used to declare a constant. A constant is similar to a variable in the sense that it represents a memory location. It differs, as I sure you can guess, in that cannot be reassigned a new value after initialization. In general, constants are a useful feature that can prevent program bugs and logic errors. Unintended modifications are prevented from occurring. The compiler will catch attempts to reassign constants new values
38942
any variable defined outside of a function or class declaration is a global.  Generally, you would declare it externally in a header file:\n\nextern int g_Counter;\n\nand define it in one of the source files:\n\nint g_Counter = 0;\n\nThe use of globals is discouraged in general.
362816
You could try and make a public const in the general declartions area ( I think its still called that ) , something like so\n\nPublic const convert = 2.54\n\nIm not sure if it will require quotes around it or not and you may have to also assign it afterwards ( Not sure on that either, I havent really used vb.net much.\n\nSo it may be \n\nPublic const convert\n\nconvert = 2.54\n\nor it could just be a simple matter of putting quotes around it ie\n\nPublic const convert = "2.54"\n\nLet me know what works :)
270512
Would be something roughly like this:\n\n#include <cstdlib>\n#include <iostream>\n#include <fstream>\n#include <string>\n\nusing namespace std;\n\n\n\nint main(void)\n{\n    string  T;\n    ifstream inf;\n    ofstream outf;\n    inf.open("myfile.txt", ios::in);\n    outf.open("YourFile.txt", ios::out);\n    while(!inf.eof()){\n        getline(inf, T, '&#92;n');\n        outf << T << "&#92;n";\n        }\n    inf.close(); \n    outf.close();\n    system("PAUSE");\n    return EXIT_SUCCESS;\n}\n\nI think.
646616
class publication\n{\n   private :\n      char title[20];\n      float price;\n   public :\n      void getdata()\n      {\n          cin>>title;\n          cin>>price;\n      }\n};\nclass books :: public publication\n{\n   private :\n      int pagecount;\n   public :\n      void getdata()\n      {\n          cin>>pagecount;\n      }\n\n};\nclass tape :: public publication\n{\n   private :\n      int playing_time;\n   public :\n      void getdata()\n      {\n          cin>>playing_time;\n      }\n};
971319
#include <iostream>\n#include <iomanip>\n\nusing namespace std;\n\nint main() {\n\n  cout << "Welcome to F&#92;'Zone&#92;n"\n      << "&#92;n"\n      << "Please select from the following menu.&#92;n"\n      << "&#92;n"\n      << "1: Quarter pounder combo&#92;n"\n      << "&#92;n"\n      << "2: Bacon burger&#92;n" \n      << "&#92;n"\n      << "3: Swiss mushroom burger&#92;n"\n      << "&#92;n"\n      << "To place your order, enter the number of the meal you would like.&#92;n"\n      << "For instance enter 2 for a Bacon Burger.&#92;n"\n      << "&#92;n"\n      << "Please enter your selection now: ";\n  char x;\n  x = getchar();\n  double total = 0.0;\n  switch (x) {\n    case '1' :\n      total = 4.59;\n      cout << "Would you like a &#92;'biggy&#92;' size? It costs $0.39 extra.&#92;n"\n          << "Type in a 'Y' or a 'N': ";\n      //x = getchar();\n      cin >> x;\n      if (x == 'Y') {\n        total += 0.39;\n        cout << "You have chosen to have a &#92;'biggy&#92;' size.&#92;n";\n      }\n      cout << "Would you like cheese with that? It costs $0.25 extra.&#92;n"\n          << "Type in a 'Y' or a 'N': ";\n      //x = getchar();\n      cin >> x;\n      if (x == 'Y') {\n        total += 0.25;\n        cout << "You have chosen to have cheese.&#92;n";\n      }\n      break;\n    case '2' :\n      // similar to 1, just change the price and messages.\n      break;\n    case '3' :\n      // similar to 1, just change the price and messages.\n      break;\n    default :\n      cout << "You have not ordered a menu item.";\n      return 1;\n  }\n  cout << "The total of your order is $" << setiosflags(ios::fixed)\n      << setprecision(2) << total << resetiosflags(ios::fixed);\n}
209710
C++ uses the same headers as C does. C++ has also some additional files for, e.g., streams and STL.
550757
I have heard this question so many times that I decided to look it up on the net and I found a very good site that explains it very well, step by step.\nSo I will simply link that one here. This is the C equivalent, you can modify it for c++!\n\nhttp://www.iwebthereforeiam.com/programming/selfWrite.asp\n\nEnjoy!
838865
What language is this?  It looks like the result of a night of unbridled passion between C, C++, and Java!\n\nSo, you know that "x->y" is equivalent to "(*x).y", right? So, even though you never used . directly, it's apparently what the compiler is seeing. Of course, . can only be used with a struct, and it is complaining that you are using it with something that is not a struct. However, the error is confusing, since the problem is really caused by a problem with pointers.\n\n Consider b[10]  (and b[9]).  b is a pointer to blocks. The [ ] operator dereferences this pointer, so that b[10] has type block, not block *.  Since -> can only be used with pointers (block *), the compiler generates an error. \n\nThink carefully about what you want to do, draw a picture on paper, and make sure your types all make sense.  Good luck.
374089
It has 2-bytes code, so you need to examine two consequent bytes. It is not C++ specific, it is PC-specific.
438944
#include<stdio.h>\n#include<conio.h>\n#include<ctype.h>\n\nint main()\n{\n  char ch;\n  cout<<"enter some text&#92;n";\n  do{\n    ch=getch();\n    putchar(ch);\n  }while(ch!='&#92;n');\n  return 0;\n}
781094
Nobody is going to do your homework for you. \n\nIf you're supposed to write code examples that illustrate how two comparable programs might look, then do this. Write some simple programs in C, and then re-write the same program in C++ but put the functions your void main calls in a class and instantiate the class.
561896
Hi,\n\nYou can start reading the basic section in C++, they teach you on what are variables, what are datatypes, and what are loops.\n\nThey will teach you how to use arrays and loops and conditionals.\n\nThat is your best bet...\n\nPick up any standard C++ book and read he intro to programming!
642129
ok, here is one declaration, of many;\n\nfloat Doc(int arr[100], int NumCt)\n{\nfloat sum = 0.0;\nfor (int i = 0; i < NumCt; i++)\nsum += arr[i];\n\nif (!NumCt)\nreturn sum;\n\nreturn sum / NumCt;\n}
387163
Use "..."\n\nI don't really get it, but there's some documentation here: http://courses.cs.vt.edu/~cs1704/notes/A02.AdvancedFunctionParameters.pdf
39247
It's a declaration.  You are not defining "int", you are only using an instance of it.  It's the same between C and C++.\n\nLocal variables are not necessarily initialized to any particular value, just globals (including namespaced and static globals)
279633
in C language, ++ operator is used to increment one to anything(variable values).. when the next language was created, it had the basic symbols and keywords as well as operations as in C plus object oriented properties..\nso they name it as an increment of C and hence "C++"..