constants Questions

2

If I have a writable buffer, I can use ctypes.c_void_p.from_buffer function to obtain a C pointer to this buffer. How to deal with non-writable buffers, however? How to form a const pointer that I...
Arabist asked 12/12, 2012 at 17:47

2

Solved

In C++, object constructors cannot be const-qualified. But - can the constructor of an object of class A know whether it's constructing a const A or a non-const A? Motivated by a fine point in the ...
Vedis asked 2/7, 2021 at 15:46

6

Solved

Technology: Java 1.5 or 1.6 Hibernate 3.4 To avoid update of column name on multiple places on change of column name or tablename, i want to have a constant file for same. I have following querie...
Natty asked 17/12, 2010 at 18:23

6

Solved

I have a situation, where I would like to have a map that does not allow to add/remove keys after initialization, but the values are allowed to change (thus I cannot simply make the map const). Ie ...
Possession asked 9/5, 2017 at 7:41

8

Solved

In programming (and math) there are variables and constants. Is there a name to describe both of them? I was thinking value, but that's not it. A value is what variables/constants contain, not what...
Kemppe asked 8/7, 2011 at 11:37

4

Solved

I am trying to create a constant name dynamically and then get at the value. define( CONSTANT_1 , "Some value" ) ; // try to use it dynamically ... $constant_number = 1 ; $constant_name = ("CONST...
Tammy asked 22/10, 2010 at 8:44

3

Solved

I am having an issue when trying to destroy an active record instance. It involves the following AR class Client < ActiveRecord::Base has_many :phone_numbers, :dependent => :destroy has_m...
Tauten asked 7/4, 2009 at 22:9

4

Solved

In Visual Studio Code, how can you automatically add const when you press (Ctrl + S)?
Payoff asked 5/8, 2022 at 7:20

1

Solved

Here is the code: #include <vector> #include <functional> class TestClass { public: const std::vector<int> &getStuff() const { return callback(); } protected: std:...
Redound asked 20/6 at 12:32

2

Solved

I have a key-value database table, where I store some settings. I would like to have these settings in a PHP constant object, since they shouldn't be editable. In PHP7 we can now do this: define...
Rimbaud asked 22/9, 2016 at 14:5

3

I'm using ESLint to make my JavaScript code style consistent. My favorite indentation level is 4 and I want my declarations style to be this: function () { let a = 1, bbb = 2; const cc = 3, d...
Feuillant asked 28/4, 2017 at 21:52

7

Solved

Python 3.4 introduces a new module enum, which adds an enumerated type to the language. The documentation for enum.Enum provides an example to demonstrate how it can be extended: >>> clas...
Karame asked 28/7, 2013 at 18:5

9

Solved

SCRPT5039: Redeclaration of const property line 1 character 1 line1: var editObj = null; This is the beginning of the file and I checked to make sure that variable is not in any other js files be...
Soppy asked 28/9, 2011 at 4:4

6

Solved

Why most of the time should I use const instead of let in JavaScript? As we know if we use const then we can't reassign value later. Then why not use let instead of const?
Consistent asked 11/12, 2016 at 13:22

7

Solved

Imagine I have a C++ class Foo and a class Bar which has to be created with a constructor in which a Foo pointer is passed, and this pointer is meant to remain immutable in the Bar instance lifecyc...
Jemappes asked 14/9, 2009 at 20:22

5

Solved

typedef char* c; const c ptr1 = "pointer"; ++ptr1; /// error const char* ptr2 = "pointer"; ++ptr2; /// runs fine Now ptr1 should be of type const char* and thus a non-const pointer, then why is i...
Hanahanae asked 8/8, 2012 at 12:53

6

Solved

Why can't I initialize non-const static member or static array in a class? class A { static const int a = 3; static int b = 3; static const int c[2] = { 1, 2 }; static int d[2] = { 1, 2 }; };...
Floatage asked 11/3, 2012 at 17:1

3

Solved

I know to define a constant, you do something like this define("CONSTANT", "Hello world."); if I want to change the value of the constant I would have to do define() again? Why couldn't I just d...
Compelling asked 19/1, 2012 at 19:0

5

I have just started learning C and a question has bugged me for a while now. If I write int i = -1; unsigned int j = 2; unsigned int k = -2; What is the type of integer literal -1 and 2 and -2, ...
Damnatory asked 31/12, 2016 at 4:53

6

Solved

My project consists of only two source files: a.cpp: const int n = 8; b.cpp: extern const int n; int main() { // error LNK2001: unresolved external symbol "int const n" (?n@@3HB) int m = n;...
John asked 15/2, 2013 at 12:24

8

Solved

Why should I write (as my collegue says): import static org.apache.commons.lang.math.NumberUtils.INTEGER_ONE; if (myIntVariable == INTEGER_ONE) { ... } instead of: if (myIntVariable == 1) { ......
Syndicalism asked 17/7, 2015 at 8:29

4

Solved

I am working on a program for my CS class. It is a simulation of a delivery company's activities at an airport. This is a very simple, small program consisting of a few header and source files an...
Forsyth asked 19/9, 2011 at 6:34

13

Solved

#include <iostream> using namespace std; class T1 { const int t = 100; public: T1() { cout << "T1 constructor: " << t << endl; } }; When I am trying to i...
Pigweed asked 24/1, 2013 at 6:53

4

Solved

I have the following code from Codeigniter index.php My understanding is that, If / of string position in $system_folder (in this case CIcore_1_7_1) is false, and if realpath function exists AND ...
Blowbyblow asked 1/10, 2009 at 20:59

2

In C++, we can use macro or constexpr (as C++11 said). What can we do in C#? Please see "Cannot declare..." comment for context: static class Constant { // we must ensure this is compile time co...
Allanallana asked 22/4, 2013 at 9:39

© 2022 - 2024 — McMap. All rights reserved.