built-in-types Questions
9
Solved
For example—say I want to add a helloWorld() method to Python's dict type. Can I do this?
JavaScript has a prototype object that behaves this way. Maybe it's bad design and I should subclass...
Atheling asked 15/1, 2011 at 7:27
2
In the interactive interpreter, if you type the following in order you can see some pretty interesting stuff:
1) help()
2) modules
3) __builtin__
When reading through the output for awhile I ca...
Blanketing asked 8/8, 2014 at 20:9
8
Solved
While looking over some code in Think Complexity, I noticed their Graph class assigning values to itself. I've copied a few important lines from that class and written an example class, ObjectChild...
Bonehead asked 6/12, 2012 at 3:57
2
Solved
I have to implement a class called ComplexNumbers which is representing a complex number and I'm not allowed to use the built in types for that.
I already have overwritten the operators (__add__, _...
Louvar asked 14/12, 2016 at 14:14
10
In C++, is string a built-in data type?
Thanks.
Flemings asked 22/3, 2011 at 8:45
1
I just wrote following program & it compiles & runs fine. (see live demo here.)
#include <iostream>
typedef int T;
int main()
{
int a=3;
std::cout<<a<<'\n';
a.~T...
Axum asked 26/8, 2015 at 3:25
1
Solved
Please read the question entirely before you think to mark it as duplicate. The statement like
int i=int();
most programmers will say that there is value initialization here & i will be value...
Mennonite asked 2/6, 2015 at 18:11
2
In other words, why does Python allow variable names which are identical to built-in type names such as int, float, list, etc? (C++ built-in type names are all reserved, in comparison). Consider th...
Dutch asked 29/5, 2015 at 8:53
3
Solved
Question: Why do uninitialized objects of built-in type defined inside a function body have undefined value, while objects of built-in type defined outside of any function are initialized to 0 or '...
Ningsia asked 5/11, 2014 at 13:24
3
Solved
I have some doubt about type conversion, could you explain me what happens in an expression like this:
unsigned int u = 10;
int a = -42;
std::cout << u - a << std::endl;
Here I know ...
Rosiorosita asked 1/9, 2014 at 15:32
1
Solved
I have read in Dr. Bjarne Stroustrup Book "The C++ Programming Language" 3rd edition that built in types have also constructors in C++ in section 10.4.2.
But then the following link says that POD ...
Nappy asked 21/7, 2014 at 14:47
3
Solved
Is there a simpler way for a class's constructor to specify that all members of built-in type should be zero-initialized?
This code snippet came up in another post:
struct Money
{
double amount...
Sanderlin asked 9/4, 2014 at 22:35
3
Solved
I would like to see if an object is a builtin data type in C#
I don't want to check against all of them if possible.
That is, I don't want to do this:
Object foo = 3;
Type type_of_foo = foo.Get...
Bung asked 11/7, 2009 at 22:21
1
Solved
I am using Python's built-in sets to hold objects of a class I have defined. For this class, I defined __eq__, __ne__, and __hash__ so that I can compare objects by my custom comparison functions. ...
Laris asked 30/4, 2013 at 18:43
4
Solved
I grew some doubts after discussing this with colleagues...
As the title asks, when can it be assumed that built-in types will be initialized to 0 instead of an unknown value?
Do the rules vary a...
Rutan asked 8/2, 2013 at 13:56
1
Solved
Consider this code:
#include <iostream>
using namespace std;
void Func(int&& i) {
++i;
}
int main() {
int num = 1234;
cout << "Before: " << num << endl;
Func(...
Bish asked 4/2, 2013 at 2:21
2
Solved
What's wrong with this code?
class MyList(list):
def __init__(self, li): self = li
When I create an instance of MyList with, for example, MyList([1, 2, 3]), and then I print this instance, all ...
Selfrestraint asked 23/1, 2013 at 16:40
1
Solved
I wonder why there doesn't exist a literal for partial function types. I have to write
val pf: PartialFunction[Int, String] = {
case 5 => "five"
}
where an literal like :=> would be short...
Stubble asked 15/3, 2012 at 23:51
7
Solved
Variables of built-in types can be value-initialized like this:
int var = int();
this way I get the default value of int without hardcoding the zero in my code.
However if I try to do similar s...
Nomarch asked 9/11, 2011 at 15:47
5
Solved
The following code (taken from here):
int* ptr = int();
compiles in Visual C++ and value-initializes the pointer.
How is that possible? I mean int() yields an object of type int and I can't ass...
Meaning asked 9/11, 2011 at 16:10
3
When subclassing builtin types, I noticed a rather important difference between Python 2 and Python 3 in the return type of the methods of the built-in types. The following code illustrates this fo...
Kismet asked 2/11, 2011 at 15:48
3
Solved
signed long long value = -2147483648;
cout << ((signed long long)value);
outputs 2147483648 (no minus sign), why?
Karli asked 4/4, 2011 at 9:37
1
Solved
Can someone explain the following behaviour:
class derivedset1(frozenset):
def __new__(cls,*args):
return frozenset.__new__(cls,args)
class derivedset2(set):
def __new__(cls,*args):
return s...
Omor asked 31/1, 2011 at 11:32
1
Solved
# Python 3
class Point(tuple):
def __init__(self, x, y):
super().__init__((x, y))
Point(2, 3)
would result in
TypeError: tuple() takes at most 1
argument (2 given)
Why? What should I do ...
Banner asked 28/1, 2011 at 10:44
5
Solved
How do I default-initialize a local variable of primitive type in C++? For example if a have a typedef:
typedef unsigned char boolean;//that's Microsoft RPC runtime typedef
I'd like to change th...
Sartor asked 6/4, 2010 at 10:50
1 Next >
© 2022 - 2024 — McMap. All rights reserved.