I have a class member myMember that is a myType pointer. I want to assign this member in a function that is declared as const. I'm doing as follows:
void func() const
{
...
const_cast<myType*>(myMember) = new myType();
...
}
Doing this works fine in VC++, but GCC gives an error with the message "lvalue required as left ...
On Ruby, when using DBM
require "dbm"
db = DBM.open("somedata")
db[1] = 2 # ok
p db[1] # gives error
does anyone know db[1] = 2 is ok, but printing out db[1] will give error?
If it requires db["1"] to be valid, then how come it doesn't apply to both cases but to one case only?
...
I want the function getCategory() to return "invalid" , instead of printing the word "invalid" (i.e instead of using printf ) when input to the function is invalid (i.e.when either height or weight are lower then zero).
please help:
#include<stdio.h>
#include<conio.h>
char getCategory(float height,float weight)
{
char invalid = '\...
Consider the following C++ Standard ISO/IEC 14882:2003(E) citation (section 5, paragraph 4):
Except where noted, the order of
evaluation of operands of individual
operators and subexpressions of individual
expressions, and the order in
which side effects take place, is
unspecified. 53) Between the previous
and next seque...
I'm coming to javascript from C background. In javascript, when I use the assignment operator to assign one object to another, does it copy the values from one to the another, or do they both now point to the same data?. Or does the assignment operator do anything in this case?
function point_type()
{
this.x = 0;
this.y = 0;
}
var ...
I have data in a CSV file. One of the column lists a persons name and all the rows that follow in that column provide some descriptive attributes about that person until the next persons name shows up. I can tell when the row has a name or an attribute by the LTYPE column, N in that column indicates that in that row the NAME value is a...
I have a Vector class, and I was testing the following unit test (using nUnit).
1 Vector test1 = new Vector(new double[] { 6, 3, 4, 5 });
2 Vector test2 = test1;
3 Assert.AreEqual(test1, test2, "Reference test");
4 test2 = new Vector(new double[] { 3, 3, 4, 5 });
5 Assert.AreEqual(test1, test2, "Reference test");
The first test i...
Greetings,
I'm sure that this is probably an incredibly stupid question, but...
What does the following line actually do?
string = @"Some text";
Assuming that "string" is declared thusly in the header:
NSString *string;
What does the "=" actually do here? What does it do to "string"'s reference count? In particular, assuming th...
may i know are(a += 10 and a = a + 10) these both the same or is there any difference or purpose is there. i got this doubt while studying about assignments in java.
...
I'm trying to find an elegant way to access the fields of some objects in some other part of my program through the use of a record that stores a byte and accesses fields of another record through the use of functions with the same name as the record's fields.
TAilmentP = Record // actually a number but acts like a pointer
private
Ord...
Hello,
Given this snippet of JavaScript...
var a;
var b = null;
var c = undefined;
var d = 4;
var e = 'five';
var f = a || b || c || d || e;
alert(f); // 4
Can someone please explain to me what this technique is called (my best guess is in the title of this question!)? And how/why it works exactly?
My understanding is that variab...
I have a function which accepts a pointer to a struct and sets a member of that struct to a specific value. However, after that assignment code is executed, and my program exits without showing any errors.
void swn_addClassToInstance(struct instanceR *instance)
{
instance->classCount = 0;
//nothing below here will run
}
I'm new to C...
I'm just starting with X++ (Java background) and I found a code like
#XYZBatchScheduling
;
...
order.Status = #geplant;
order is a record to a table with a Status column.
My question: what is the meaning of #USRBatchScheduling and #geplant ("geplant" is "planned" in german) and eventually where to find it's definition.
I suppose it...
Hello,
The C# scripting environement in Unity3D (runned under Mono) has a nice behavior when detroying objects. All the references that point to the destroyed object gets automaticly null :
GameObject ref1 = (GameObject)Instantiate(obj);
GameObject ref2 = ref1;
if (ref1 != null)
Debug.Log("ref1 is not null");
...
How do you go about using the return value optimization?
Is there any cases where I can trust a modern compiler to use the optimization, or should I always go the safe way and return a pointer of some type/use a reference as parameter?
Is there any known cases where the return value optimization cant be made?,
Seems to me that the retu...
Recently I've time off of school for a few days and wanted to do a small program(s) experiment in c++ dealing with memory address.
I wanted to see is that if a currently running program (Let call it Program A) that created a pointer to an int object in the heap, can be seen by another program and be modified (Program B).
So for Progr...
I have a wire that is about 4 levels deep and I really don't want the hassle of having to propagate it up the hierarchy. Is there any way to assign the wire using some sort of referencing? I know I can access the wire by typing:
cca.cpu0.cca3_cpu.nc1_cp_checkpoint
but
assign cca.cpu0.cca3_cpu.nc1_cp_checkpoint = checkpoint;
doesn...
I am writing a tic-tac-toe game in plt-scheme as my AI course project.
The idea for gui is a grid with 9 boxes, each with a canvas, using panes ...
When the user click on a canvas, 'X' or 'O' will be drawn accordingly ...
The question is how can I catch mouse click event on canvas?
I found out I need to use on-event, but still don't kno...
Most languages make it easy to take an array like [1, 2, 3] and assign those values to variables a, b, and c with a single command.
For example, in Perl you can do
($a, $b, $c) = (1, 2, 3);
What's the corresponding trick in PHP?
[Thanks so much for the lightning fast answer! I know this is a trivial question but all the obvious goog...
I just made my first steps moving into Objective-C. I have a very simple question about how arrays works.
I have two .m files:
1)
Line = origin[6];
forloop(i...i++) {
origin[i]=7;
}
[buildSubview:origin];
2)
Line response[6];
-(id)buildSubview:(Line[])origin {
*response=*origin;
NSLog(@"response[1]=%o",response[1]);
...