Member Avatar

Does C++ have predefined text constants / string constant to be used as replacements for digits when testing errorcodes ? An example: if (errcode == 17){ std::cout << "The file already exists!" << std::endl; } To make it more readable I can write: if (errcode == FILE_ALREADY_EXISTS){ std::cout << "File already exists!" << std::endl; } Of course I can define an integer constant with the name FILE_ALREADY_EXISTS and give it the value 17, but (maybe) there are some predefined string constants / text constants defined in a standard header-file somewhere ?

Member Avatar
0
14
Member Avatar

in the code const char* buf what is the constant? The pointer or buf?

Member Avatar
0
25
Member Avatar

i have this code so to hinder from access when the url is directly type i understand BASEPATH is a constant but can anyone give me idea on how to cofigure the basepath? do i need to create a constant folder and constant php file? if (! defined('BASEPATH')) exit('No direct script access allowed')

Member Avatar
0
20
Member Avatar

I have a warning that I can;t get rid of: Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated. I am pretty sure it is becasue I have not dimentioned the variable but how do you dimention an IO.memorystream. Here is the code: Photograph1.Image = Photograph1.Image.FromStream(New IO.MemoryStream(arr)) Any help would be greatfull. The programms runs and works, its just got those annoying warnings.

Member Avatar
0
24
Member Avatar

#include <iostream> class Hello { public: void Test() { std::cout << "Testing" << std::endl; } }; class Hi { public: Hi() :hello(new Hello()) {} ~Hi() { delete hello; } void Testing() const { hello->Test(); } private: Hello * hello; }; int main(int argc, char ** argv) { Hi hi; ; hi.Testing(); return 0; } As i know a non-constant member function cant be called inside a constant member function but how the above code has been compiled successfully and giving the expected result .

Member Avatar
0
8
Member Avatar

double & val = 66.6; //illegal const double & val = 66.6; //legal I was just doing some demo programs and came through the above concept but not able to identify what exactly the need of the above concept . what magic exactly const is doing in the second case ? can anyone please let me know where exactly we can use this concept in real time programming

Member Avatar
0
4
Member Avatar

Programe #1 inside file.h class File { public: static const int var = 9; }; inside main.cpp #include <iostream> #include "file.h" using namespace std; int main() { File f; cout << f.var; return 0; } Programe #2 inside file.h int Globalvar ; class File { public: static const int var = 9; }; inside main.cpp extern int GlobalVar; #include <iostream> #include "file.h" using namespace std; int main() { cout << GlobalVar; return 0 ; } Program#1 is running fine, but program#2 gives linker error: error LNK2005: "int GlobalVar" (?x@@3HA) already defined in file.obj I know the header files are never …

Member Avatar
0
5
Member Avatar

Hi, recently i started taking lessons on c programming and my first assignment was to make programm which would name all the perfect multiperfect or superperfect numbers within a set (whose limits will be given as #define constants) and their percentage. Anyway apart from any logic errors (which i would be very glad if someone pointed out!!) i'm facing some compilation difficuties. Specifically the code is #include <stdio.h> #define MAXM 6 #define MAXNUM 400000 main() { int n, sum, i, k, m, totdis, totsup, totmul, total, totper; totdis=0; total=0; totmul=0; totper=0; totsup=0; for (n = 1 ; n <= MAXNUM …

Member Avatar
0
7
Member Avatar

Hello, I am newb with php I got a strange message error, that is: [U]Notice: Use of undefined constant y - assumed 'y' in /home/www/healthforum.uib.no/htdocs/ohcsurvey/survey/sp1.php on line 139 [/U] I am making a survey where the user , by cliking radio buttons, can choose between yes or no to a question. for example: [CODE]<u>Do you agree or not?</u><br/> <b><input type="radio" name="c1" value="y" />I do <br/> <input type="radio" name="c1" value="n" />I don't</b> [/CODE] (the forms are not on the same page but are linked to it properly) The yes is transformed by 1 and the no is transformed by 0 with …

Member Avatar
0
21
Member Avatar

I'm having some trouble defining constants correctly. I know the format should be this: Const CONSTANT_NAME [As ConstantType] = value But I'm a little unclear of how to word it. So here is the Line I need to change into a Constant. Normally I would have a BAS file do this but I can't find one (Refer to other post). Code: With oXLSheet.Range("A1:A10") .Font.ColorIndex = 50 .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter End With That's the entire section that I'm dealing with. I don't think all of it needs to be constants, but maybe it does? I'm not sure. All …

Member Avatar
0
2
Member Avatar

Hello, I created this little asci art in java, and am wondering how to implement a constant int value that can be changed to make the picture bigger/smaller etc.. these are my loops: [CODE] for(int i = 5;i>=0;i--){ for(int j = 1;j<=i;j++){ System.out.print("P"); } for(int j = 5;j>=i;j--){ System.out.print(" "); } for(int j = 0;j<=i*2-1;j++){ System.out.print("M"); } for(int j = 10;j>=i*2+1;j--){ System.out.print("\\"); } for(int j = 5;j>=i;j--){ System.out.print(" "); } for(int j = 1;j<=i;j++){ System.out.print(":"); } } [/CODE]

Member Avatar
0
5
Member Avatar

Hi members, just a simple question, how would I show a constant in an UML diagram? For example, here is a double field the class contains. - radius : double But how would the constant PI (3.14159...) be shown? - PI : constant?? Future thanks for the responses!

Member Avatar
0
7
Member Avatar

I promice everone that I have looked and looked and looked for a solution, I'm not just having a problem and being lazy putting it on daniweb... haha :) ull have to trust me, ive even googled it :O! Ok, so I am wondering, if I wanted to return a single (non aray) pointer to an array (yes, I know, pointers arn't arrays, I mean, doesn't return the start of the array) which is un modifiable, will this work: [CODE=C++]GLdouble rotMatrix[2][2];[/CODE] [CODE=C++]const GLdouble * getRotMatrix(int row, int column){return(&rotMatrix[row][column]);};[/CODE] I know I can just test it... But I'm worried that I …

Member Avatar
0
3
Member Avatar

HI CONSTANTS in my customer site are affecting my admin site. i don't know why. also when i browse for admin site and if index.php file is not available home.php file loads. i find this very weird... can anyone please help me? following is some of the errors it generates. this file C:\xampp\htdocs\currency_rates\lib\config.php is in my customer site not in admin but the file im calling in my admin home page is C:\xampp\htdocs\currency_rates\admin\lib\config.php it seems both are being called but i can't understand how???? first i thought it might be a session conflict then i used different browsers but results …

Member Avatar
0
9
Member Avatar

Hi All, Can you please help me to understand why the following code is behaving this way? I think both outputs should be 1 ( 1 means const T), but its not!! [CODE] template <typename T> struct IsConst{ enum {isConst = 0}; }; template <typename T> struct IsConst<const T>{ enum {isConst = 1}; }; template <typename T> void print(T val){ cout << IsConst<T>::isConst << endl; //prints 0 } int main() { const int x = 10; print(x); //why dynamic argument deduction deducting it as normal integer? cout << IsConst<const int>::isConst << endl; //prints 1 return 0; } [/CODE] why dynamic …

Member Avatar
1
4
Member Avatar

Problem when i am using $webRoot / $srvRoot as a value for a variable or in defining a constant Code & problem is below: [CODE]<?php ini_set('display_errors', 'On'); error_reporting(E_ALL); $thisFile = str_replace('\','/', __FILE__); $docRoot = $_SERVER['DOCUMENT_ROOT']; $webRoot = str_replace(array($docRoot, 'testing.php'), '', $thisFile); $srvRoot = str_replace('testing.php', '', $thisFile); define('WEB_ROOT', $webRoot); //error on this line Variable Undefined define('SRV_ROOT', $srvRoot); //error on this line Variable Undefined echo 'thisFile- '.$thisFile ;//works perfect echo "<br>"; echo 'docRoot- '.$docRoot;//works perfect echo "<br>"; echo 'webroot- '.$webRoot ;//works perfect echo "<br>"; echo 'srvroot- '.$srvRoot ;//works perfect ?>[/CODE] what is it that i am doing wrong? Pls help me!

Member Avatar
0
3
Member Avatar

I'm looking to re-order a table while keeping the table's id column constant. ie, Links has entries in no particular order, whereas LinksPopular is a duplicated table but I want it ordered by category X, while leaving the id category unchanged. That way the first most popular is at id 1, second at id 2, etc, instead of the index's being all over the place. Does anyone know how to do this? I've tried dropping the id column then re-adding it in order, but I couldn't get that to work with the auto_increment, and it doesn't seem very efficient. Thanks …

Member Avatar
0
10

The End.