how to write a "charge simulation method" program in C or C++? It's to calculate electric distribution and also electric potential of two different dielectrics. I have attached the diagram of the shape of the electrode that needs to be investigated.
I have been looking and i'm stuck on this. I wrote this program to find quarks and their charge and mass but i need it to give me 5 different ones. so i made an array but when i run it it gives me this
"Unhandled exception at 0x001631c6 in DiasQuarkP1V0.exe: 0xC0000005: Access violation reading location 0xd5bf0c38." and it shows the xstring library.
this is my main, is their anything wrong with my code?
#include "StdAfx.h" #include <stdio.h> #include <string> using namespace std; int main() { Quark solution[5]={};
I've been trying for more than one month to access a method found in a library called libcocosnas_static.a. I'm using Cocos2d-X version 2.0.4. The library has been used many times by my company to make games using cocos2d-1.0.1-x-0.12.0 without any problem.
This is what I've done: 1- I added the include paths of the library to both eclipse and Android.mk 2- Included the .h file using #include "NASPlatformUtil.h" 3- Added the libcocosnas_static.a file to the proj.androidobjlocalarmeabi folder 4- Added "LOCAL_WHOLE_STATIC_LIBRARIES += cocosnas_static" to the Android.mk file 5- Called the function using: NASPlatformUtil:: openUrl("http://xxx.xxx.com/");
I can right click on the function, click Open Declaration and get it without any problem, but the compiler keeps on giving me that dreaded error...
I have to write a program to take packets of information destined for certain ports then provide the current message using the packets I've gotten so far. Packets can come out of order, so when asked for the message, packets that haven't arrived yet are skipped and the next packet is appended. After giving the message, I have to delete all the current packets as well as ones that are received late, after the packets that were supposed come after the late packet were already provided in the message.
Data:Up to 1000 ports, numbered 0-64000, and each message can contain up to 1000 packets.
Write an email simulator that processes mail at an average of 40 messages per minute. As messages are received, they are placed in a queue.assume that the messages arrive at an average rate of 30 messages per minute.messages must arrive randomly.
Each minute, you can dequeue up to 40 messages and send them. Assume that 25% of the messages in the queue cannot be sent in any processing cycle.use a random number to determine whether a given message can be sent. If it can't be sent, enqueue it.
Run the simulation for 24 hours, At the end of the simulation, print the statistics that show:
-The total messages processed. -The average arrival rate. -The average number of messages sent per minute. -The average number of messages in queue in a minute. -The number of messages sent on the first attempt, the number sent on the second attempt, and so forth. -The average number of times messages had to be requeued (do not include the messages sent the first time in this average)
Well, actually I've done a part of the coding. But how to continue it. And here is my code :
#include <iostream> using namespace std; #define SIZE 40 class Queue { int queue[SIZE]; int head, tail; public: Queue(); void Enq(int num);
My Project is to Dynamically Link 2 Software for Co-simulation n C/C++. So that Output of One Software becomes Input of Other automatically . at present we input the parameters manually in both the software . what to do so that it pick up values itself and gives the output by solving each and everything at once in both the software .
I'm trying to create program that reads in commands from an input file, and accordingly creates, connects or destroys logic gate primitives (and gates, or gates). Additionally, I'm trying to modify a previous program that I wrote to do this using QThreads, where each gate is placed in its own QThread. I'm trying to avoid using invokemethod, and I'm sure this method can work. My specific issue that I'm having trouble debugging is in my connect code block in main.cpp. Whenever I try to reference a gate specified by the input file that is NOT the true or false gate (I have one of each and they are attached to any gate that needs a true or false input), I get only a NULL reference. This includes attempting to reference the gate in my gatelist QMap. Calling gatelist.value(newCommand.at(1)) causes the program to hang, and the connect statements referencing said gate return errors about connecting a signal or slot of a NULL pointer.
Here is main.cpp: #include <QPointer> #include <QMap> #include <QDebug> #include <QString> #include <QFile> #include <QTextStream>
[Code] ...
My accompanying class declarations can be found here : [URL] ....
Anyhow, I have a program due Wednesday that is along the lines of the classic Bank Teller simulation using Queue's.
Unlike most of these programs, I have to integrate my own Queue, QueueNode, Teller, and Customer classes. I have attached all of these headers below plus the main file.
Now the error: While I'm sure there are other issues with the code, it will not let me create a new customerQueue (of Queue type) object as such:
Queue<Customer> customerQueue;
The error it is giving me is:
no matching constructor for initialization of 'Queue<Customer>'
I'm currently working on a simulation of the motion of magnets on a rod. As part of it, there are arrays of the properties of the magnets:
long double *accelerations; // These will later be dynamically allocated depending on the number long double *velocities; // of magnets long double *positions;
However, when I go to compile this, the compiler gives me these error for the pointers:
error: two or more data types in declaration of 'accelerations' error: two or more data types in declaration of 'velocities' error: two or more data types in declaration of 'positions'
Apparently, the compiler isn't recognising long double* as a type and is instead reading is as the two types long and double*.
I'm supposed to build a banking simulation program around the BankAcct class, which provides the following service: create new account with unique account number (maximum 5 accounts created in a single test running); deposit/withdraw; print information of all existing account. I was running a test program with only 2 services first, namely creating new account and depositing, but the program just keep on crashing and I couldn't figure out why.
#include <iostream> #include <sstream> #include <string> using namespace std;
I have a question similar to the one here: [URL] .....
The main difference is I would like to pass a method of derived class as a parameter to some other method in its template base class.
template <typename BaseType> class Base { public: typedef void (Base::*Callback)(int A);
[Code] .....
The above is an example which does not compile. My compiler complains that the two BaseMethod() calls in DerivedMethod() are invalid uses of non-static member function.
Is this not possible to do, or is my syntax simply wrong? All I want is to be able to pass as an an argument to a method in the base class from the derived class some callback as a variable for the base class to invoke later.
#include <iostream> using namespace std; struct A { virtual void f() { cout<<"A "; } };
[code]...
I would expect that both examples 2 & 3 will give me the same result.I tried to figure it out but I could not. Both are references of a base class type, that get a derived object.
Q1 : why is the difference between them ?
As I see it, its kind of a mix between pointer - which in case of virtual method that was override in derived class - would give me the derived method (e.g. "B") and between regular object - which in case of virtual method that was override - would give me the specific method (Still "B"). So, example 2 "use" it as a regular object and example 3, "use" it as pointer.
Q2 : How should I refer to it ? I am using VS2008.
I have 2 classes with a Function with the same definition (both inherited from the same base class) and in my derived class I derive from both of those 2. Is it possible to use the Methods of both classes? for example with an other name?
class A { protected: int print(int a) { std::cout << "int A: " << a << std::endl; } }; class B : A
[Code] ....
is there something like using C::print as printc;?
The Problem, I have a Sprite class that derives from a Rectangle with properties Position, Size, Origin and Angle and a Text class that derives from Rectangle. Now i have a Button class deriving from both Sprite and Text.
- The Position, when moving the Button i have to change the position of both so i Implemented a new Method which calls SetPosition from the Sprite and the Text. - The SetSize just affects the Button so i just did using Sprite::SetSize; - The angle affects both so i just implemented a new Method and hide the other two
The problem is here: - The Origin: writing button.SetOrigin(-1,0) should set the Origin of the Button and writing button.SetTextOrigin should set the Origin of the text.
Should i just reimplement a Mehtod named SetTextOrigin and call Text::SetOrigin from there and hide the button.Text::SetOrigin or is there something like using Text::SetOrigin as SetTextOrigin?
It has been a few years since I have had to do this, but I need to declare a method in my base class, but produce no code for it. Then when this library is used by my second project I will derive a class from this base class and put the code into it there. How is this possible? I used to know how but do not remember how now.
The library is a static library designed for linking with both 32bit and 64bit Windows applications to handle a lot of the tedious stuff with Windows programming. The method in question handles specific command inputs. However, since each program that uses this library will have different uses for these commands, I want to leave it up to the user to code their own handling, but require it to be coded in the derived class.
I want to access the body of the Add() of a list in c# to see how it works, but it only just gives me the declaration.
[DebuggerTypeProxy(typeof (Mscorlib_CollectionDebugView<>))] [DebuggerDisplay("Count = {Count}")] [Serializable] public class List<T> : IList<T>, ICollection<T>, IList, ICollection, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable { public void Add(T item); // thats all. I tried go to declaration but still gives me this line of code. This is from metadata in Visual studio. }
How this thing work. It just a declaration not a definition yet its still doing something. How is that possible.
Allow users to enter their name and favorite saying in a single method that gets invoked two times. If I can only return one value at a time, how am I suppose to get name and favorite saying out of UserInput()?
I have to create a program that accepts 10 numbers from user, and then I display a list of the numbers, the smallest one and the higher number. I have problems with displaying the smallest and higher number, I tried to Array.Sort and Array.Reverse, but I don't know what I'm doing wrong, this is my code:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace SmallAndLargeGUI
[Code] ...
Also I tried to set
if (x == 10) numberTextBox.Enabled = false;
to block the textbox when the user has entered 10 numbers, but didn't work either...
I am trying to input a recursion method. The code compiles, however, it is only giving me a value of 1. I am wanting the value of 5 when it is compiled. Why is this?
#include <iostream> using namespace std; int number(int x) { if (x == 1)