Search Results

Search found 50973 results on 2039 pages for 'class names'.

Page 28/2039 | < Previous Page | 24 25 26 27 28 29 30 31 32 33 34 35  | Next Page >

  • Changes to data inside class not being shown when accessed from outside class.

    - by Hypatia
    I have two classes, Car and Person. Car has as one of its members an instance of Person, driver. I want to move a car, while keeping track of its location, and also move the driver inside the car and get its location. However, while this works from inside the class (I have printed out the values as they are calculated), when I try to access the data from main, there's nothing there. I.e. the array position[] ends up empty. I am wondering if there is something wrong with the way I have set up the classes -- could it be a problem of the scope of the object? I have tried simplifying the code so that I only give what is necessary. Hopefully that covers everything that you would need to see. The constructer Car() fills the offset array of driver with nonzero values. class Car{ public: Container(float=0,float=0,float=0); ~Container(); void move(float); void getPosition(float[]); void getDriverPosition(float[]); private: float position[3]; Person driver; float heading; float velocity; }; class Person{ public: Person(float=0,float=0,float=0); ~Person(); void setOffset(float=0,float=0,float=0); void setPosition(float=0,float=0,float=0); void getOffset(float[]); void getPosition(float[]); private: float position[3]; float offset[3]; }; Some of the functions: void Car::move(float time){ float distance = velocity*time; location[0] += distance*cos(PI/2 - heading); location[1] += distance*sin(PI/2 - heading); float driverLocation [3]; float offset[3]; driver->getOffset(offset); for (int i = 0; i < 3; i++){ driverLocation[i] = offset[i] + location[i]; } } void Car::getDriverPosition(float p[]){ driver.getPosition(p); } void Person::getPosition(float p[]){ for (int i = 0; i < 3; i++){ p[i] = position[i]; } } void Person::getOffset(float o[]){ for (int i = 0; i < 3; i++){ o[i] = offset[i]; } } In Main: Car * car = new Car(); car->move(); float p[3]; car->getDriverPosition(p); When I print driverLocation[] inside the move() function, I have actual nonzero values. When I print p[] inside main, all I get are zeros.

    Read the article

  • how to access class and its functions from another class

    - by vbNewbie
    This is my first major application using multiple classes. It is written in vb and I know about creating objects of the class and using that instance to call functions of the class. But how do I create an object with constructors to allow another program written in C# to access my classes and functions and accept things from the program. Hope this makes sense.

    Read the article

  • Prototype Add Class to Class

    - by a1anm
    I have a few div's like this in my page: <div class="listing-type-list catalog-listing"> I would like to append a class to the div when I hover over it then remove it when I mouseout? How can this be done with prototype?

    Read the article

  • Put Java Threading Class into a separate class

    - by erlord
    Consider following SWT code example: http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet151.java?view=co How can I separate the inline defined class? Thread thread = new Thread() { public void run() { ... } }; I want to define a separate class which updates the table just like it does here. How do I pass the list back to the table? Example code?

    Read the article

  • C# class type - How to determine whether it is a standard .net framework class

    - by HorstWalter
    C# / .net framework What is the most reliable way to determine whether a class (type) is a class provided by the .net framework and not any of my classes or 3rd party library classes. I have tested some approaches The namespace, e.g. starting with "System." The Codebase of the assembly, where the dll is located All this "feels" a little clumsy though it works. Question: What is the easiest and most reliable way to determine this?

    Read the article

  • ActionScript 3 - access variables in main application class from instantiated class

    - by Herter
    I have a initApp.as which instantiates a class which needs to access the "currentState" property and the States array as well. However we cannot get this to work as we cannot see how we can access this information. Within initApp.as currentState is accessed via "this.currentState". This does not work in the class which is instatiated within initApp.as. The following error is thrown: "Access of undefined property currentState." Anyone know how this can be solved?

    Read the article

  • EmguCV: Can't find ColorType abstract class

    - by roverred
    EmguCV ColorType wiki I'm trying to create a ColorType abstract class variable but it says the type or namespace does not exist. However I have access to the classes that extend it. I also tried adding all Emgu.CV libraries and have all the references and .dll files in the bin folder. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Drawing; using Emgu.CV; using Emgu.CV.Util; using Emgu.CV.GPU; using Emgu.CV.ML; using Emgu.CV.OCR; using Emgu.CV.OpenCL; using Emgu.CV.Stitching; using Emgu.CV.VideoStab; using Emgu.CV.Structure; using Emgu.CV.UI; using Emgu.CV.CvEnum; namespace mySpace { class foo { private ColorType the color; //invalid can't find ColorType private ColorType myColor = new Gray(); //invalid } } Any ideas? Thanks for any help.

    Read the article

  • F# Class with Generics : 'constructor deprecated' error

    - by akaphenom
    I am trying to create a a class that will store a time series of data - organized by groups, but I had some compile errors so I stripped down to the basics (just a simple instantiation) and still can't overcome the compile error. I was hoping some one may have seen this issue before. Clas is defined as: type TimeSeriesQueue<'V, 'K when 'K: comparison> = class val private m_daysInCache: int val private m_cache: Map<'K, 'V list ref > ref; val private m_getKey: ('V -> 'K) ; private new(getKey) = { m_cache = ref Map.empty m_daysInCache = 7 ; m_getKey = getKey ; } end So that looks OK to me (it may not be, but doesnt have any errors or warnings) - the instantiation gets the error: type tempRec = { someKey: string ; someVal1: int ; someVal2: int ; } let keyFunc r:tempRec = r.someKey // error occurs on the following line let q = new TimeSeriesQueue<tempRec, string> keyFunc This construct is deprecated: The use of the type syntax 'int C' and 'C ' is not permitted here. Consider adjusting this type to be written in the form 'C' NOTE This may be simple stupidity - I am just getting back from holiday and my brain is still on time zone lag...

    Read the article

  • IList<Item> Collection Class accessing database

    - by Mike
    Hi, I have a database with Users. Users have Items. These Items can change actively. How do you access the items in a collection type format? For the user, I fill all the user properties at the time of instantiation. If I load the user's items at the time of the instantiation, and the items change, they will have old data. I was thinking, maybe I need an ItemCollection class and have that a field/property apart of the user class, that way to traverse all the user's items I could use a foreach loop. So, my question is, what is the best practice/best way of accessing the items from a database using some sort of collection? On accessing the particular Item, it needs to get the latest database information, and when the user does do a foreach loop, the latest item information must be available. I.e. What I'm trying to do Console.WriteLine(User.Items[3].ID); returns 5. //this updates the item information and saves it to the database. User.Items[3].ID = 13; //Add a new item to the database. User.Items.Add(new Item { id = 17}); foreach (Item item in User.Items) { //this would traverse all items in the database. //not some cached copy at the time of instantiation of the user. }

    Read the article

  • Can operator<< in derived class call another operator<< in base class in c++?

    - by ivory
    In my code, Manager is derived from Employee and each of them have an operator<< override. class Employee{ protected: int salary; int rank; public: int getSalary()const{return salary;} int getRank()const{return rank;} Employee(int s, int r):salary(s), rank(r){}; }; ostream& operator<< (ostream& out, Employee& e){ out << "Salary: " << e.getSalary() << " Rank: " << e.getRank() << endl; return out; } class Manager: public Employee{ public: Manager(int s, int r): Employee(s, r){}; }; ostream& operator<< (ostream& out, Manager& m){ out << "Manager: "; cout << (Employee)m << endl; //can not compile, how to call function of Employee? return out; } I hoped cout << (Employee)m << endl; would call ostream& operator<< (ostream& out, Employee& e), but it failed.

    Read the article

  • Jquery class changing works, but doesn't effect another function like it should

    - by Qwibble
    So I have content boxes that close and expand when you click an arrow. The content box has two classes for telling whether it is open or closed (.box_open, .box_closed). A hover function is assigned to box_open so when it is open and you hover over the header, the arrow appears. However, I don't want this to happen when the box is closed, as I want to arrow to remain visible when the box is closed. When the box closes, the box_open class is removed, but the function assigned to that class still works. Here's the jquery code for the two functions. You can also see them in the head of the demo below. // Display Arrow on Box Header Hover $(".box_open").hover( function () { $(this).find('a').show(); }, function () { $(this).find('a').hide(); } ); // Open and Close Boxes: $(".box_header a").click( function () { $(this).parent().next('.box_border').stop().toggle(); $(this).parent().toggleClass("box_open"); $(this).parent().toggleClass("box_closed"); return false; } ); Can anyone take a look at what the problem is? Here's the demo url: Demo Url

    Read the article

  • Passing Derived Class Instances as void* to Generic Callbacks in C++

    - by Matthew Iselin
    This is a bit of an involved problem, so I'll do the best I can to explain what's going on. If I miss something, please tell me so I can clarify. We have a callback system where on one side a module or application provides a "Service" and clients can perform actions with this Service (A very rudimentary IPC, basically). For future reference let's say we have some definitions like so: typedef int (*callback)(void*); // This is NOT in our code, but makes explaining easier. installCallback(string serviceName, callback cb); // Really handled by a proper management system sendMessage(string serviceName, void* arg); // arg = value to pass to callback This works fine for basic types such as structs or builtins. We have an MI structure a bit like this: Device <- Disk <- MyDiskProvider class Disk : public virtual Device class MyDiskProvider : public Disk The provider may be anything from a hardware driver to a bit of glue that handles disk images. The point is that classes inherit Disk. We have a "service" which is to be notified of all new Disks in the system, and this is where things unravel: void diskHandler(void *p) { Disk *pDisk = reinterpret_cast<Disk*>(p); // Uh oh! // Remainder is not important } SomeDiskProvider::initialise() { // Probe hardware, whatever... // Tell the disk system we're here! sendMessage("disk-handler", reinterpret_cast<void*>(this)); // Uh oh! } The problem is, SomeDiskProvider inherits Disk, but the callback handler can't receive that type (as the callback function pointer must be generic). Could RTTI and templates help here? Any suggestions would be greatly appreciated.

    Read the article

  • Qt 101: Why can't I use this class?

    - by Airjoe
    I have experience with C++ but I've never really used Qt before. I'm trying to connect to a SQLite database, so I found a tutorial here and am going with that. In the QtCreator IDE, I went to Add New -- C++ Class and in the header file pasted in the header the header from that link and in the .cpp file I pasted the source. My main.cpp looks like this: #include <QtGui/QApplication> #include "mainwindow.h" #include "databasemanager.h" #include <qlabel.h> int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); DatabaseManager db(); QLabel hello("nothing..."); if(db.openDB()){ hello.setText("Win!"); } else{ hello.setText("Lame!"); } hello.resize(100, 30); hello.show(); return a.exec(); } And I'm getting this error: main.cpp:13: error: request for member 'openDB' in 'db', which is of non-class type 'DatabaseManager()' Can anyone point me in the right direction? I know "copypaste" code isn't good, I just wanted to see if I could get DB connectivity working and I figured something like this would be simple... thanks for the help.

    Read the article

  • Accessing bitmap array in another class? C#

    - by Marius Mathisen
    I have this array : Bitmap[] bildeListe = new Bitmap[21]; bildeListe[0] = Properties.Resources.ål; bildeListe[1] = Properties.Resources.ant; bildeListe[2] = Properties.Resources.bird; bildeListe[3] = Properties.Resources.bear; bildeListe[4] = Properties.Resources.butterfly; bildeListe[5] = Properties.Resources.cat; bildeListe[6] = Properties.Resources.chicken; bildeListe[7] = Properties.Resources.dog; bildeListe[8] = Properties.Resources.elephant; bildeListe[9] = Properties.Resources.fish; bildeListe[10] = Properties.Resources.goat; bildeListe[11] = Properties.Resources.horse; bildeListe[12] = Properties.Resources.ladybug; bildeListe[13] = Properties.Resources.lion; bildeListe[14] = Properties.Resources.moose; bildeListe[15] = Properties.Resources.polarbear; bildeListe[16] = Properties.Resources.reke; bildeListe[17] = Properties.Resources.sheep; bildeListe[18] = Properties.Resources.snake; bildeListe[19] = Properties.Resources.spider; bildeListe[20] = Properties.Resources.turtle; I want that array and it´s content in a diffenrent class, and access it from my main form. I don´t know if should use method, function or what to use with arrays. Are there some good way for me to access for instanse bildeListe[0] in my new class?

    Read the article

  • Unmanaged DLL (exporting Dialog) + Class Library (DLL) + no Windows Style/Themes

    - by Gohlool
    Hi, I have a managed application TestApplication.exe in C# and Application.EnableVisualStyles() is allready called. I have a Class Library MySharedCode.dll also in C# which uses [DLLImport()] to import some External dialogs out of an unmanaged dll. Well, now I am using (add reference) MySharedCode.dll in my TestApplication.exe and call a function MyTestConfigDlg() out of it. TestClass.MyTestConfigDlg(); OK, everything works fine and I get my dialog, but the dialog has NO XP style/themes? I just wanted to see if it's general problem with managed/unmanged modules, so I used the [DLLImport()] to call the same MyTestConfigDlg() dialog but this time directly in my TestApplication.exe! WOW! Worked as I expected. The Dialog was in XP Style/Themes! so, anybody here who can help me out? FYI: I also tried (just for test) to call MessageBoxA() API call in my Class Library Dll which later called by my TestApplication.exe and the MessageBoxA() had also no Style/Themes! Thanks in advance!

    Read the article

  • Trying to output a list using class

    - by captain morgan
    Am trying to get the moving average of a price..but i keep getting an attribute error in my Moving_Average class. ('Moving_Average' object has no attribute 'days'). Here is what I have: class Moving_Average: def calculation(self, alist:list,days:int): m = self.days prices = alist[1::2] average = [0]* len(prices) signal = ['']* len(prices) for m in range(0,len(prices)-days+1): average[m+2] = sum(prices[m:m+days])/days if prices[m+2] < average[m+2]: signal[m+2]='SELL' elif prices[m+2] > average[m+2] and prices[m+1] < average[m+1]: signal[m+2]='BUY' else: signal[m+2] ='' return average,signal def print_report(symbol:str,strategy:str): print('SYMBOL: ', symbol) print('STRATEGY: ', strategy) print('Date Closing Strategy Signal') def user(): strategy = ''' Which of the following strategy would you like to use? * Simple Moving Average [S] * Directional Indicator[D] Please enter your choice: ''' if signal_strategy in 'Ss': days = input('Please enter the number of days for the average') days = int(days) strategy = 'Simple Moving Average {}-days'.format(str(days)) m = Moving_Average() ma = m.calculation(gg, days) print(ma) gg is an list that contains date and prices. [2013-10-01,60,2013-10-02,60] The output is supposed to look like: Date Price Average Signal 2013-10-01 60.0 2013-10-02 60.0 60.00 BUY

    Read the article

  • Retrieve only the superclass from a class hierarchy

    - by user1792724
    I have an scenario as the following: @Entity @Table(name = "ANIMAL") @Inheritance(strategy = InheritanceType.JOINED) public class Animal implements Serializable { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "S_ANIMAL") @SequenceGenerator(name = "S_ANIMAL", sequenceName = "S_ANIMAL", allocationSize = 1) public int getNumero() { return numero; } public void setNumero(int numero) { this.numero = numero; } . . . } and as the subclass: @Entity @Table(name = "DOG") public class Dog extends Animal { private static final long serialVersionUID = -7341592543130659641L; . . . } I have a JPA Select statement like this: SELECT a FROM Animal a; I'm using Hibernate 3.3.1 As I can see the framework retrieves instances of Animal and also of Dog using a left outer join. Is there a way to Select only the "part" Animal? I mean, the previous Select will get all the Animals, those that are only Animals but not Dogs and those that are Dogs. I want them all, but in the case of Dogs I want to only retrieve the "Animal part" of them. I found the @org.hibernate.annotations.Entity(polymorphism = PolymorphismType.EXPLICIT) but as I could see this only works if Animal isn't an @Entity. Thanks a lot.

    Read the article

  • A public struct inside a class

    - by Koning Baard
    I am new to C++, and let's say I have two classes: Creature and Human: /* creature.h */ class Creature { private: public: struct emotion { /* All emotions are percentages */ char joy; char trust; char fear; char surprise; char sadness; char disgust; char anger; char anticipation; char love; }; }; /* human.h */ class Human : Creature { }; And I have this in my main function in main.cpp: Human foo; My question is: how can I set foo's emotions? I tried this: foo->emotion.fear = 5; But GCC gives me this compile error: error: base operand of '-' has non-pointer type 'Human' This: foo.emotion.fear = 5; Gives: error: 'struct Creature::emotion' is inaccessible error: within this context error: invalid use of 'struct Creature::emotion' Can anyone help me? Thanks P.S. No I did not forget the #includes

    Read the article

< Previous Page | 24 25 26 27 28 29 30 31 32 33 34 35  | Next Page >