# **OLD** # [URL=http://s127.photobucket.com/user/yoda3ddd/media/codemap_zps4115ff7e.jpg.html][IMG]http://i127.photobucket.com/albums/p158/yoda3ddd/codemap_zps4115ff7e.jpg[/IMG][/URL] The Data Namespace Core Friend Module Func Public OkButton As Button Public CancelButton As Button Public ProgBar As ProgressBar Private Sub ProgressLoop() Do Func.ProgBar.PerformStep() Threading.Thread.Sleep(1) Loop End Sub #Region "Constants" Public Const DataRoot As String = "C:\AFormData\" Public Const IMG_PATH As String = "C:\AFormData\img" Public Const LoadImage As String = "C:\AFormData\img\codemap_zps4115ff7e.jpg" Public Const LINE_TERMINATOR As String = ">>" Public Const LoadImageX As Integer = 0 Public Const LoadImageY As Integer = 0 Public Const LoadBarFailedMessage As String = "Loading Bar Denied" Public Const ResizeMessage As String = "Current Form Resizing" Public Const NoCommandMsg As String = …

Member Avatar
Member Avatar
+0 forum 6

I recently came accross this code: Mat3D R_z(double RotAngle) { const double S = sin (RotAngle); const double C = cos (RotAngle); Mat3D U; U.m_Mat[0][0] = +C; U.m_Mat[0][1] = +S; U.m_Mat[0][2] = 0.0; U.m_Mat[1][0] = -S; U.m_Mat[1][1] = +C; U.m_Mat[1][2] = 0.0; U.m_Mat[2][0] = 0.0; U.m_Mat[2][1] = 0.0; U.m_Mat[2][2] = 1.0; return U; } My question: why should the keyword `const` be used in this case? The variables C and S are IMHO just a bit of syntactic sugar, to make the rest of the code somewhat easier to read.

Member Avatar
Member Avatar
+0 forum 15

Hi, I do have doubt regarding const declaration in copy constructor. Can anyone let me know why do we need const reference in copy constructor, as we already know reference itself is const pointer.So why we should use const as a prefix in copy constructor. Regards, Mohan

Member Avatar
Member Avatar
+0 forum 4

The luxuries we now have in the amount of pixels on a screen to draw some amazing graphs with, were lacking in the early days of computing. Most of the time you had to resort to rude printed output. It wasn’t that bad always. Sometimes it was and still is sufficient; just to have a quick preview of what a function would look like. Here I present some code that does just that. It plots a function to the console. I included a screen dump(which passed through Paint) just to show what it looks like. You could also use the …

Member Avatar
Member Avatar
+1 forum 2

I need to modify an object in a QVector. I'm the `[]` operator to point to the object, which is overloaded with a constant and a non-constant version. The problem I'm having is that I don't know how to specify the non-const version, so I get compile errors telling me that it couldn't convert a constant to a non-constant object.

Member Avatar
Member Avatar
+0 forum 2

I have started writing a *really* basic tile engine in C++ and I'm not entirely sure when to use const return values. Should I use them in cases like this class A { private: Rectangle hitBox; public: A(); const bool Collision(const Rectangle& hitBox2); }; or is it totally pointless?

Member Avatar
Member Avatar
+0 forum 2

Dear all, I am certainly not an expert in C++ development but after some time, I had some code running and compiling for a bio-informatics tool. As always in Science, I changed my area of research of a while and when I came back to my tool, I had changed my computer (and my gcc version) in between. In the program, I run several threads that call a function. This is where the function run_es_pval is called (and where the error message takes place) for (int i = 0; i < threadNb; i++) { int start = i * datasetPerThread; …

Member Avatar
Member Avatar
+0 forum 2

can anyone tell me whether we can use const variables for case ...eg I wrote the following code: const int i=2; int j=0; switch(1) { case i:printf("hii"); } now ...this snippet is running properly in turbo c but not in dev cpp... likewise if we use this const variable as array index during initialisation...would it work... can anyone explain ...at what time memory is allocated for variables...

Member Avatar
Member Avatar
+0 forum 12

I can't figure out what this error is saying. Error: C:\Users\Kyle\School\CS 372\Statistician\Statistician.cpp||In function 'bool operator==(const statistic&, const statistic&)':| C:\Users\Kyle\School\CS 372\Statistician\Statistician.cpp|225|error: passing 'const statistic' as 'this' argument of 'float statistic::sum()' discards qualifiers| C:\Users\Kyle\School\CS 372\Statistician\Statistician.cpp|225|error: passing 'const statistic' as 'this' argument of 'float statistic::sum()' discards qualifiers| C:\Users\Kyle\School\CS 372\Statistician\Statistician.cpp|226|error: passing 'const statistic' as 'this' argument of 'int statistic::length()' discards qualifiers| C:\Users\Kyle\School\CS 372\Statistician\Statistician.cpp|226|error: passing 'const statistic' as 'this' argument of 'int statistic::length()' discards qualifiers| C:\Users\Kyle\School\CS 372\Statistician\Statistician.cpp|227|error: passing 'const statistic' as 'this' argument of 'float statistic::max()' discards qualifiers| C:\Users\Kyle\School\CS 372\Statistician\Statistician.cpp|227|error: passing 'const statistic' as 'this' argument of 'float statistic::max()' discards qualifiers| C:\Users\Kyle\School\CS 372\Statistician\Statistician.cpp|228|error: passing 'const …

Member Avatar
Member Avatar
+0 forum 4

Hey everyone, I am working on a function that reads a text file (portion below) of data points arranged in two columns and stores the numbers only in an array of signal[2500][2]. The problem is, I need to do some search and replace on [I]some[/I] of the data points. Some are mV and msec, while others are uV and usec. As there are negative signs on some values, I cannot simply choose the first six places in each line (or similar). My intent is to convert those lines that are mV and ms to uV and usec and then store …

Member Avatar
Member Avatar
+0 forum 4

Hi, I want to declare an array of constant values in my header file, and this array cannot be changed in the main code. const uchar x[4] = {1, 2, 3, 4} does not work, cos the linker will complain that the address space overflow. Is there any way to do this? Thanks in advance! YYE

Member Avatar
Member Avatar
+0 forum 3

Okay, so I'm new to C++ programming and am working on a simplified project to find Expected taxable income. The project states that I have to set SI, HH, MJ, and MS as const int variables equal respectively to 5700, 8350 11400, and 5700. const int SI = 5700; const int HH = 8350; const int MJ = 11400; const int MS = 5700; right? Well then I have to prompt the user to input cin >> ??? >> number_exceptions >> income >> Itemized_deductions >> real_estate_taxes_paid; I didn't actually use those names for the other variables but my question is …

Member Avatar
Member Avatar
+0 forum 1

I have a the following snippet of code [CODE]string const& symbol::at(int index) const { assert(index<symbol_data.vector::size()); return symbol_data.vector::at(index); }[/CODE] This does not compile successfully, instead, I get complaints about [CODE]error: ‘template<class _Tp, class _Alloc> class std::vector’ used without template parameters[/CODE] Now, I think this has something to do with the fact that I'm returning a const reference to an object that this function is treating as const. How can I modify my two lines of code to satisfy const correctness?

Member Avatar
Member Avatar
+0 forum 11

Hey, it's me again. Again with a topic that has been covered here but reading through the old threads didnt help me to solve my problem. And I am pretty clueless at the moment. Consider the class passenger_queue with 2 functions, namely: [CODE]int passenger_queue::get_passengers_waiting() const { // Insert your code here. Use the iterator defined in this class. int sum = 0; } return sum; } [/CODE]and [CODE]std::vector<passenger*>& passenger_queue::passengers_at_floor(int floor_) { return _waiting_passengers[floor_]; }[/CODE] member variables are: [CODE] typedef std::map<int, std::vector<passenger*> > p_map; p_map _waiting_passengers; std::vector<passenger> _passengers;[/CODE] First of all the comment in the get_passengers_waiting. Apart from the constructor which …

Member Avatar
Member Avatar
+0 forum 11

Hi I am trying to call a 3rd party method which relies on const char* I want to pass an arbitrary value. The (broken) code below should show what I'm trying to do. [CODE] #include <iostream> #define MAX 1000 // 3rd party stuff void ConstPtrMethod(const char* s) { std::cout << s << std::endl; } // My stuff: int main() { const char* ConstBuffer; for (int i = 0; i < 10; i++) { char* buf; buf = ConstBuffer; sprintf(buf, "%d", i); ConstPtrMethod(ConstBuffer); } }[/CODE] I'm a cpp noob btw. What I want to know is why the line buf = …

Member Avatar
Member Avatar
+0 forum 3

Hey all, I'm implementing a hash table for a spell checker and need some assistance on vector const_iterator - at least I think that's where the problem lies. Can anyone assist in diagnosing how to fix these compiler errors? I initially got this error, which i think will come back once I fix the is_present function: main.cpp:101: undefined reference to `ns_1::table<word_record>::is_present(int) const' I am now getting the below errors and can't figure out if I have a data type issue or am just defining the const_iterator incorrectly or ... Note that line 67 in the errors corresponds to line 11 …

Member Avatar
Member Avatar
+0 forum 8

Hello everybody! I'm trying to understand following code. [CODE] #include "stdafx.h" #include <iostream> using namespace std; class Circle; class Square; class Triangle; class Shape { public: virtual bool Check(const Shape&)const = 0; virtual bool Check(const Circle&)const = 0; virtual bool Check(const Square&)const = 0; virtual bool Check(const Triangle&)const = 0; }; class Circle : public Shape { public: bool Check(const Shape& s)const {return s.Check(*this);} bool Check(const Circle&)const {cout << "Circle & Circle\n"; return true;} bool Check(const Square&)const {cout << "Circle & Square\n"; return true;} bool Check(const Triangle&)const {cout << "Circle & Triangle\n"; return true;} }; class Square : public Shape …

Member Avatar
Member Avatar
+0 forum 9

The End.