Unlike new and delete operators malloc does not call the constructor when an object is created. In that case how must we create an object so that the constructor will also be called.
Hi,
I have a table in an Access 2007 database, all fields are of type text. Can the following be done using the where clause. If so how?
SELECT * from Table1 WHERE (ColumnDate is between 26th and 19th of march 2010)
SELECT * from Table1 WHERE (ColumnAge is between 25 and 40)
The usual < <= operators dont seem to work.
Thanks,
Does java have a built-in method to compare precedence of two operators? For example, if I have a char '/' and a char '+' is there a method I can call that compares the two and returns true/false if the first is greater than the second (e.g. true)?
What are all operations supported by function pointer differs from raw pointer?
Is , < , <= , =operators supported by raw pointers if so what is the use?
I'm mainly a Python programmer, and it is often described as being "executable pseudo-code". I have used a little bit of AppleScript, which seems to be the most English-like programming language I have ever seen, because almost operators can be words, and it lets you use "the" anywhere (for example, this stupid example I just came up with:
firstnumber = 1
secondnumber = 2
if the firstnumber is equal to the secondnumber then
set the sum to 5
end if
is a valid AppleScript program. Are there any programming languages that are even more English-like than these?
What is your opinion of using the infix operator hack in production code? Issues:
The effect this will have on speed.
The potential for a clashes with an object with these operators already defined. This seems particularly dangerous with generic code that is intended to handle objects of any type.
It is a shame that this isn't built in - it really does improve readability
Is there a programming language that uses inflections (suffixing a word to add a certain meaning) instead of operators to express instructions? Just wondering.
I need to monitor the direction a user is indicating using the four directional arrow keys on a keyboard in ActionScript 3.0 and I want to know the most efficient and effective way to do this.
I've got several ideas of how to do it, and I'm not sure which would be best. I've found that when tracking Keyboard.KEY_DOWN events, the event repeats as long as the key is down, so the event function is repeated as well. This broke the method I had originally chosen to use, and the methods I've been able to think of require a lot of comparison operators.
The best way I've been able to think of would be to use bitwise operators on a uint variable. Here's what I'm thinking
var _direction:uint = 0x0; // The Current Direction
That's the current direction variable. In the Keyboard.KEY_DOWN event handler I'll have it check what key is down, and use a bitwise AND operation to see if it's already toggled on, and if it's not, I'll add it in using basic addition. So, up would be 0x1 and down would be 0x2 and both up and down would be 0x3, for example. It would look something like this:
private function keyDownHandler(e:KeyboardEvent):void
{
switch(e.keyCode)
{
case Keyboard.UP:
if(!(_direction & 0x1)) _direction += 0x1;
break;
case Keyboard.DOWN:
if(!(_direction & 0x2)) _direction += 0x2;
break;
// And So On...
}
}
The keyUpHandler wouldn't need the if operation since it only triggers once when the key goes up, instead of repeating. I'll be able to test the current direction by using a switch statement labeled with numbers from 0 to 15 for the sixteen possible combinations. That should work, but it doesn't seem terribly elegant to me, given all of the if statements in the repeating keyDown event handler, and the huge switch.
private function checkDirection():void
{
switch(_direction)
{
case 0:
// Center
break;
case 1:
// Up
break;
case 2:
// Down
break;
case 3:
// Up and Down
break;
case 4:
// Left
break;
// And So On...
}
}
Is there a better way to do this?
Are these two equivalent? In other words, are the ++ and -- operators atomic?
int i = 0;
return ++i;
AtomicInteger ai = new AtomicInteger(0);
return ai.incrementAndGet();
So, I want to resize images to a FIXED width, but proportional height.
I have been trying a wide range of operators:
380x242#
380x242
380!x242
380x242<
none of them have the desired effect. Any help? I want it to fill or resize to the 380 width, then resize / shrink the height by the same factor it used to shrink or resize the image to 380 wide.
i came across this line is stroustrup An operator function must either be a member or take at least one argument of a user-defined type (functions redefining the new and delete operators need not).
Dont operator new and operator delete take an user defined type as one of their arguments?
what does it mean, am i missing something here
Hi, I already have my operators for, by example, eat banana problem
[#op{
action = [climb, on, {object}],
preconds = [[at, {place}, {object}], [at, {place}, me],
[on, floor, me], [on, floor, {object}], [large, {object}]],
add_list = [[on, {object}, me]],
del_list = [[on, floor, me]]
},
But how can I use it in the function solve(Problem, depth_first, []). And depth_first (Problem, Start) - search_tree(Problem, container.stack, Start).
I came across this code today whilst reading Accelerated GWT (Gupta) - page 151.
public static void getListOfBooks(String category, BookStore bookStore) {
serviceInstance.getBooks(category, bookStore.new BookListUpdaterCallback());
}
public static void storeOrder(List books, String userName, BookStore bookStore) {
serviceInstance.storeOrder(books, userName, bookStore.new StoreOrderCallback());
}
What are those new operators doing there? I've never seen such syntax, can anyone explain?
Hi
I have a code like
A = B|C|D|E;
Throwing the warning "suggest parentheses around arithmetic in operand of |"
Expecting that expression needs high priority paranthesis for operators, tried the following ways:
A=(B|C)|(D|E);
one more as : A=(((B|C)|D)|E);
Still the same warning persists.
Please help me in resolving this.
Thanks,
Sujatha
I know that there are certain "special" methods of various objects that represent operations that would normally be performed with operators (i.e. int.__add__ for +, object.__eq__ for ==, etc.), and that one of them is list.__setitem, which can assign a value to a list element. However, I need a function that can assign a list into a slice of another list.
Basically, I'm looking for the expression equivalent of some_list[2:4] = [2, 3].
I am creating an mssql database table, "Orders", that will contain a varchar(50) field, "Value" containing a string that represents a slightly complex data type, "OrderValue".
I am using a linqtosql datacontext class, which automatically types the "Value" column as a string.
I gave the "OrderValue" class implicit conversion operators to and from a string, so I can easily use implicit conversion with the linqtosql classes like this:
// get an order from the orders table
MyDataContext db = new MyDataContext();
Order order = db.Orders(o => o.id == 1);
// use implicit converstion to turn the string representation of the order
// value into the complex data type.
OrderValue value = order.Value;
// adjust one of the fields in the complex data type
value.Shipping += 10;
// use implicit conversion to store the string representation of the complex
// data type back in the linqtosql order object
order.Value = value;
// save changes
db.SubmitChanges();
However, I would really like to be able to tell the linqtosql class to type this field as "OrderValue" rather than as "string". Then I would be able to avoid complex code and re-write the above as:
// get an order from the orders table
MyDataContext db = new MyDataContext();
Order order = db.Orders(o => o.id == 1);
// The Value field is already typed as the "OrderValue" type rather than as string.
// When a string value was read from the database table, it was implicity converted
// to "OrderValue" type.
order.Value.Shipping += 10;
// save changes
db.SubmitChanges();
In order to achieve this desired goal, I looked at the datacontext designer and selected the "Value" field of the "Order" table.
Then, in properties, I changed "Type" to "global::MyApplication.OrderValue".
The "Server Data Type" property was left as "VarChar(50) NOT NULL"
The project built without errors.
However, when reading from the database table, I was presented with the following error message:
Could not convert from type 'System.String' to type 'MyApplication.OrderValue'.
at System.Data.Linq.DBConvert.ChangeType(Object value, Type type)
at Read_Order(ObjectMaterializer1 )
at System.Data.Linq.SqlClient.ObjectReaderCompiler.ObjectReader2.MoveNext()
at System.Linq.Buffer1..ctor(IEnumerable1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Example.OrdersProvider.GetOrders()
at ... etc
From the stack trace, I believe this error is happening while reading the data from the table. When presented with converting a string to my custom data type, even though the implicit conversion operators are present, the DBConvert class gets confused and throws an error.
Is there anything I can do to help it not get confused and do the implicit conversion?
Thanks in advance, and apologies if I have posted in the wrong forum.
cheers / Ben
I'm hoping there are some Cell Phone Operator gurus here today.
Would anyone be able to explain how Operators achieve the Visual Voicemail feature on the iPhone (and I assume other newer smart phones)?
If a new cell phone operator that distributed SIM cards wanted to utilise the visual voicemail feature on unlocked iPhone's what services need to be in place to be able to support it?
Is there an open spec or is it completely proprietary?
I realize this is a basic question but I have searched online, been to cplusplus.com, read through my book, and I can't seem to grasp the concept of overloaded operators. A specific example from cplusplus.com is:
// vectors: overloading operators example
#include <iostream>
using namespace std;
class CVector {
public:
int x,y;
CVector () {};
CVector (int,int);
CVector operator + (CVector);
};
CVector::CVector (int a, int b) {
x = a;
y = b;
}
CVector CVector::operator+ (CVector param) {
CVector temp;
temp.x = x + param.x;
temp.y = y + param.y;
return (temp);
}
int main () {
CVector a (3,1);
CVector b (1,2);
CVector c;
c = a + b;
cout << c.x << "," << c.y;
return 0;
}
from http://www.cplusplus.com/doc/tutorial/classes2/ but reading through it I'm still not understanding them at all. I just need a basic example of the point of the overloaded operator (which I assume is the "CVector CVector::operator+ (CVector param)").
There's also this example from wikipedia:
Time operator+(const Time& lhs, const Time& rhs)
{
Time temp = lhs;
temp.seconds += rhs.seconds;
if (temp.seconds >= 60)
{
temp.seconds -= 60;
temp.minutes++;
}
temp.minutes += rhs.minutes;
if (temp.minutes >= 60)
{
temp.minutes -= 60;
temp.hours++;
}
temp.hours += rhs.hours;
return temp;
}
from "http://en.wikipedia.org/wiki/Operator_overloading"
The current assignment I'm working on I need to overload a ++ and a -- operator.
Thanks in advance for the information and sorry about the somewhat vague question, unfortunately I'm just not sure on it at all.
Have you ever had to use bit shifting in real programming projects? Most (if not all) high level languages have shift operators in them, but when would you actually need to use them?
As 359494 indicates they are basically identical except '===' also ensures type equality and hence '==' might perform type conversion. In Douglas Crockford's JavaScript: The Good Parts, it is advised to always avoid '=='. However, I'm wondering what the original thought of designing two set of equality operators was.
Have you seen any situation that using '==' actually is more suitable than using '==='?
I want to my make a search-statement and query things like this
select * from table where col like '%vkvk%'
But with trial and error I've come to the conclusion that access doesn't work with LIKE or
wildcard operators. Does anybody have some other solutions because I ain't so in to access actually, so I really don't know.
As a part of my univercity work I have to write a program in LIDIL and describe its operators and functions but I can't find any documentation on this language. Naturally I've tried to google but nothing found on the first 40 pages of search results so I gave up.
SO is my last hope. Any trace of info about LIDIL is fine for me.