Programming :: Subscript Operator For A List Class?

Jun 27, 2010

how to overload the subscript operator ([]) for a list class?

Code:
template <typename T>
class list
{
public:
struct node

[Code]...

View 1 Replies


ADVERTISEMENT

Programming :: C++ Operator Overloading Within Already Overloaded Operator

Apr 16, 2011

I'm having a bit of an issue using overloaded operators in an already overloaded operator. In my following code, I have overloaded the && operator to compare two Course objects. The operator in turn goes to a function which calls other overloaded operators to compare private object variables of that object to compare them.

View 8 Replies View Related

Programming :: Can't Get The OR Operator To Work?

Apr 18, 2011

I'm having a bit of trouble getting the OR operator to work.This is the code that I have:

global.php:
Code:
$vars["admin link"] = "<a href='/path/to/admin.php'>Admin</a>";
$vars["admin ip"] = "xxx.xxx.xxx.xx1";
$vars["admin ip2"] = "xxx.xxx.xxx.xx2";

[Code]...

View 7 Replies View Related

Programming :: TCL AND Operator (&) On A Binary Value?

May 1, 2010

I have a binary value which I receive from a controller. Say this binary value is 42. Just plain hex 42. If you would look at that byte in a debugger you would see 42.Now this value hold 8 bits each indicating a high or a low output. So 0x42 = 01000010b. Which means bits 1 and 6 are '1'.When I would want to find out which bits are set and which are not in a language like C, I simply do:

Code:

mask = 0x80;
if (binval & mask) {...}
etc..

However I am programming in TCL, and I try to do:

Code:

set mask 0x80
if { [expr ($binval & $mask) > 0] } {...}
etc...

this fails. At the moment the expr is executed, $binval is evaluated and substituted so the expression I am evaluating is

Code:

set mask 0x80
if { [expr ('B' & '0x80') > 0] } {...}
etc...

Eventually I got it working by converting the $binval into a '0x42' string value, like this:

Code:

binary scan $binval c byte
set byte [format "0x%0x" $byte]
set mask 0x80
if { [expr ($byte & $mask) > 0] } {...}
etc...[

Then the expression yields what I want. But this seems so stupid and clumsy. Isn't there a better way where I can compare two binary values without conversions?

View 14 Replies View Related

Programming :: No Match For 'operator<<' In '((HttpRequest*

Jul 13, 2011

I have a simple program from book C++ cookbook, page 291, 8.3, Using Constructors and Destructors to manage resources (or RAII), but it can not get compiled in my g++

------------------------------------------------------------------------------------------------
// Example 8-3. Using constructors and destructors
#include <iostream>
#include <string>
using namespace std;

[code]....

View 2 Replies View Related

Programming :: Getting A Comparison Operator To Work?

Feb 8, 2010

I'm very new at Bash scripting and have a bone head issue that I'm trying (and failing) to resolve. I cannot get this one IF statement to work, it seems the comparison operator does not think the resulting number from the $b*$c+$b operation is an integer even though it is a number. Below is a small proof of concept script with the bit I'm having trouble with.

Code:
#! /bin/bash
a=800
b=700
c=.15
if [ "$a" -le "$(echo "($b*$c+$b)"|bc)" ]

[Code]...

View 6 Replies View Related

Debian Programming :: Square Bracket Operator?

Sep 1, 2014

Is there a way to achieve the following with the square bracket operator?I have a class:

Code: Select allclass A
{
public:
    void SetValue(int index, Item* B);
private:
    int m_iCount;
    ItemCollection Item_Collection;

[code]....

The probelm is that I am not just blindly assigning whatever given on the right hand side to the returned value from operator [], I need to verify it's not NULL, and it is not already there in the Item_Collection, and I also need to increase the count.

View 5 Replies View Related

Programming :: Operator For Floating Point Comparison?

May 10, 2011

I know it is wrong to use the "==" operator to compare the equality of two floating point numbers. Logically it would seem that if the "==" operator is not usable for floating point comparison, then the "<=" operator would also not be usable. Is this true? The lack of google search results on this topic made me think that it must be true. If that is true, then is it true that the only way to compare floats with <= or >= is with something like the code below? Code: bool smaller_than_or_equal(float a, float b) {

if ( fabs(a-b) < EPSILON){return true;}
else if (a < b) {return true;}
else {return false;}

} I think this is a general question, but if specifics are necessary, I am using the C++ language to code at the moment.

View 5 Replies View Related

Programming :: C++ Cin Doesn't Wait For Input By Operator

Jan 4, 2010

I am trying to learn C++.I implemented a simple archive program, and I am in a situation in which the user is prompted by a menu to make a choice.So I have some cout instruction to illustrate the possible choices and then

int choice;
cin>>choice;

and everything works fine.I introduced this code in a "while" loop that checks wether the choice made by the user is valid or not:

bool check=true;
int choice;
while(check)
{
cin>>choice;
if(the choice is valid) {...;check=false}
else cout<<"please make an other choice"
}

What is happening is that if by mistake the user introduces a character in place of a number, the loop repeats indefinitely because the program, when it get to the "cin" instruction, does not pauses to wait for a new input.

View 7 Replies View Related

Programming :: Print Increment Operator In Perl?

Apr 25, 2010

Can one of you point me towards a comprehensive print function tutorial in perl? I was under the impression that everything within quotes will get interpolated - but I am running into exceptions where it is not desirable to run some varaibles under quotes.

ordinal.pl
1 #!/usr/bin/perl
2 $idx = 1;
3 foreach $letter (a..z) {
4 print "Letter #",$idx++," is: $letter
";
5 #print "Letter # $idx++ is: $letter

[Code]...

View 9 Replies View Related

Programming :: Python Equivalent Of C Ternary Operator?

Jun 12, 2010

I've been reading and googling, etc. I've seen some things, but not a definite explanation of this. What is the appropriate way to mimic a C ternary operator using Python? Isn't there an exact proper way to do it? Any difference for using lambda functions? I'm sorry, but I've been searching and it's ambiguous to me how this should be handled. I would appreciate a person's help on this. I came up with this link, but I'm wondering if I'm missing something.[URL]...

So, is that it? In Dive Into Python, it's using the and-or trick. Well, if the above post is the full explanation,

View 6 Replies View Related

Programming :: Ostream<< Operator With Double Variable Is Not Accurate?

Mar 27, 2010

I have tryed out this operator on program:

Code:

#include <iostream.h>
#include <iomanip.h>
#include <fstream.h>
ofstream myfile;

[code]...

which definitly is not the same number. I guess somewhere in the convertion from double to char* ("<<") something is not right and what can i do to save these double numbers in an accurate manner in a file?

View 14 Replies View Related

Programming :: String Comparison - [: =: Unary Operator Expected?

Nov 23, 2010

I would like to compare the nmlookup result of IP's stored in the file ips with a list of PC names stored in the file pcs.

Code:
for line in `cat "ips"`
do

[code]....

View 2 Replies View Related

Programming :: C++: Assignment Operator Copy All The Members Also For Structures Containing STL Objects?

Sep 26, 2010

does the assignment operator copy all the members also for structures containing STL objects strings,vectors,vectors of vectors...)? I did try it on my platform,and it works that way (copying all the fields),but i was wondering if it is a standard behavior or not.

View 2 Replies View Related

Programming :: Build A Simple Program For C Programming Class?

Feb 12, 2011

im trying to build a simple program for my C programming class, this is the source code

#include <stdio.h>
int main()
{
int length, width, length, height, area, perimeter;
perimeter = width + length + height;
area = width * length + heigth;

[Code]...

i dont see any error (you might)but every time i run it it runs but after it asks me to input for the width i do it but it doesn't take me to the length, it just stays blank until i input another value in the same place for the width, it asks me for 4 inputs in total i don;t know why, and after i run it different times it gives me different values for the perimeter and are. how can I fix this?

View 5 Replies View Related

Ubuntu :: Evolution Error Object Class EMFolderTree Doesn't Implement Property 'paste-target-list' From Interface 'ESelectable'

May 24, 2011

When I start evolution from the terminal I get this: (evolution:3265): GLib-GObject-CRITICAL **: Object class EMFolderTree doesn't implement property 'paste-target-list' from interface 'ESelectable' The program still starts though. I am fairly new to Ubuntu.

View 2 Replies View Related

OpenSUSE Install :: Cannot Compile Vdrift-2009-06-15 - Warning: The Options Class Is Deprecated; Use The Variables Class Instead

Mar 12, 2010

I have a problem with compiling vdrift-2009-06-15 using scons. As the source that i obtained only supports scons i cannot use make. the error that i get when i try to compile it in GNOME Terminal is: scons: Reading SConscript files ... scons: warning: The Options class is deprecated; use the Variables class instead.
File "/home/mohit/Download/vdrift-2009-06-15/SConstruct", line 9, in <module>

scons: warning: The BoolOption() function is deprecated; use the BoolVariable() function instead.
File "/home/mohit/Download/vdrift-2009-06-15/SConstruct", line 13, in <module>
Checking for C++ header file asio.hpp... (cached) yes
Checking for C++ header file boost/bind.hpp... (cached) yes
Checking for C++ header file GL/gl.h... (cached) yes
Checking for C++ header file GL/glu.h... (cached) yes
Checking for C++ header file SDL/SDL.h... (cached) yes
[Code]........

View 4 Replies View Related

Programming :: Passing Class To Itself (CPP)?

May 18, 2010

I'm struggling with the issue of passing a vector of a class to itself, here's what state its in now... (tried many variations, but without direction).

Code:
#include <iostream>
#include <string>

[code]...

View 2 Replies View Related

Programming :: C++: Defining A New Class - Periodic B.c?

Apr 9, 2010

I am trying to make a periodic boundary condition type function, using an existing class given to me in lecture notes, but am having some trouble! Effectively, I am trying to make an array such that, for a point in any row of a 2D matrix ("Matrix(i,j)"), the command "next_i[i]" will return "(i+1)%L", where L is the number of data points in the row. This will enable me to select a point to the right of any point in the matrix: "Matrix(next[i],j)"

[Code]....

View 1 Replies View Related

Programming :: Use A Class Inside A Struct?

Apr 8, 2011

Is is possible to use a class inside a struct? I keep getting segmentation fault with this code:

Code:

struct my_struct {
unsigned count;
std::string msg;

[code]....

View 3 Replies View Related

Programming :: Unable To Compile Class For JSP?

Mar 15, 2011

My new guy has created several functioning webpages on his machine with TOMCAT 6 with Sun JDK, yet our machines use TOMCAT 5.5 with Open JDK, which his webpages don't show. Do you have any idea how to make them work? The error showing in a browser:

Code:
HTTP Status 500 -
type Exception report
message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception org.apache.jasper.JasperException: Unable to compile class for JSP:

[Code]...

View 2 Replies View Related

Programming :: How To Set Up Global Class In JAVA?

May 10, 2011

I've had to do some code in java, a language I'm very much unfamiliarly with so please excuse my incorrect use of terms. The basic outline of my problem is I create a class object as a local within a swing button function it works fine. If I create it as a global ( with I think I need to do ) within main, then prototype it with the other swing objects at the bottom of the file when it is called it causes a host of problems. I think the easiest way is to show it.

View 2 Replies View Related

Programming :: How To Modify ArrayList From Outside Of Class?

Mar 10, 2010

Okay so I'm working on a program here as I'm learning java,I have an array that is initialized with 5 objects that are hard coded. I have made a GUI that takes the input needed and creates an object with those values.I need to add that object to the ArrayList that I have previously made.Okay, so I have three classes, guiclass.java, main.java and gladiator.java Objects are made and defined in "gladiator".Main contains my public static void main section, launches my gui, creates my five hard coded objects, creates my ArrayList and adds my five hard coded objects to the ArrayList.Now, I need to add the object that I generated in the guiSection [action Listener]to the ArrayList that I created in my main class's public static void main string... section. Problem is my arraylist "cannot be resolved" from guiclass.

View 13 Replies View Related

Programming :: Md5 In Java Without Using MessageDigest Class

Sep 18, 2010

I am looking to write a function to return an MD5 hash in Java but I don't want to us the MessageDigest class as I am using the J2ME framework which doesn't include it.

View 3 Replies View Related

Programming :: Php And Variable Class Names?

Sep 30, 2010

How can I handle the situation below so that the "Fatal Error" message is not shown. It would be ideal if I could supply a default class to be used. I'd prefer to not use: ini_set() to supress the errors but actually be able to "handle" the error.

Code:
<?php
class MyClass

[code]....

View 2 Replies View Related

Programming :: Possible To Communicate Values Between Class?

Feb 24, 2009

I have a application in C++, and now I have two class. MyDialog is the class that main function launch. In MyDialog class there are four elements and when I click over theese elements, there is a MousePressEvent that launch other class, Touchpad class. So, in some moments, I have loaded two class. My question is, how can pass a value from Touchpad class to MyDialog class, when I close (destroy) Touchpad class. In a few words, is it possible to communicate values between class?

View 5 Replies View Related

Programming :: Implement A Set Class (like In Stl) Using A Vector?

Sep 3, 2010

i need to implement a Set class(like in stl) using a vector.Here is my code that doesnt work corectly:

Code:
#include <iostream>
#include <vector>
template<class T>
class Set
{

[Code]....

View 2 Replies View Related

Programming :: Implement C_str() For A String Class?

Oct 19, 2010

How can I implement c_str() for a string class?

View 2 Replies View Related

Programming :: Declaring A Vector Inside A C++ Class?

Mar 23, 2010

Is it not possible to declare a vector inside a C++ class ? Have a look at the following code:

Code:

#include <stdio.h>
#include <iostream>
#include <malloc.h> // malloc
#include <strings.h> // bzero

[code]....

View 2 Replies View Related

Programming :: Default Port For UDPWriter Class?

May 9, 2011

This is a really specific question, but maybe someone can help. I'm debugging someone else's code, and they call a UDPWriter and specify an IP address and port, and I'm trying to make sure this multicast traffic goes over a certain port. How can I determine which port the UDP defaults to and change it?

It's confusing to me because I'm not familiar with all the layers the OS sends traffic through before it goes through the interface. Is there maybe some simpler way to tell the OS to send multicast traffic over both interfaces?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved