I had written a "DLL" in VB.NET a year or two ago to read and set MP3 tags. I want to write this exact same library in C++ so I can convert it in my droid project, and to get a hands on introduction to C++. So far this attempt has been a total mind melt!
I am finally wrapping my head around .cpp and .h files so there is light at the end of this tunnel. Here is my problem now:
I wrote the VB project with properties for each tag in the MP3 file, then I could get and set them - easy stuff.
When I try this in C++ I get compile error: a property can only appear within the definition of a managed type. I can usually stumble through Google searches and figure out this type of stuff on my own, but this one is stumping me -- I think I am missing some fundamental stuff here.
My code:
// MP3Tags.h
#pragma once;
#include <string>
using namespace std;
using namespace System::IO;
I have an inventory array in a class called inventory. This class is in a different program. How do I access and add to this array for my main program?
I'd like to start out by adding an array to a C++ class. I'd like to be able to reference the array using a class object that I create, for example:
Class is Stone.
Stone Bob is an instance of "stone" that I name "Bob".
"Bob.array[1] = "granite";" tells the compiler that the second element in the array (with the first being the zeroth element) is a string containing "granite".
I'll eventually want to extend this to an n x m matrix within the "stone" class that can be referenced as: Bob.matrix[1][3]="lignite";
I tried to make this work using a text again and again last night to no avail. My code is below.
NOTE: Since I am dynamically allocating memory space, I'd like to avoid memory leaks when using this class with dynamically allocated arrays and matrices. Not sure how to do this. Also need some insight into "destructor", and why my simple version reduced to a comment below doesn't seem to please the compiler.
CODE FOLLOWS:
Code: // AINOW.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #include <string> using std:: string; using std:: cout; using std:: endl; using std:: cin;
void replace(string oldstring, string newstring) { int stroldstringpos=b.find(oldstring); b.replace(stroldstringpos,newstring.length(),newstring); }
i have 1 error in these function that i'm confused. imagine the newstring size is more big than the oldstring, how can change the string, but only change the oldstring and add what left? see these:
I am trying to add matrices a and b. I am getting an error in the "add" function, probably because I have m[i] in it, and m is not an array. What is the correct way of writing the "add" member function here?
Also, although the "read" and "write" member functions of the class are working just fine, do you think there is a better way of writing them?
Code: #include <iostream> #include <cmath> #include <iomanip> using namespace std; const int rows=3; const int columns=3;
I am trying to add data from a file that would go into a class that would later go into a vector of a class. I'm not really sure how to do it exactly. Here is the code:
Champion_Info.h
#ifndef CHAMPION_INFO_H_INCLUDED #define CHAMPION_INFO_H_INCLUDED #include <vector> #include <string> using namespace std; class Champ_Info {
I have a .cpp file which contains 5 smaller defined classes. In my missile class I have a default constructor and a constructor that I invoke
class Missile{ private: bool isHuman;
[Code]...
My issue is when creating and adding the pointer object; it doesn't seem to create a new instance of the class-the Missile objects all share the same xPos value which is always the first xPos when the "fire" command is given. The "Missile *missile = new Missile(xPos, yPos, true);" line does not seem to create a new instance of the object with different variables but instead creates a new object with the same variables. Is it necessary for me to always make a separate .cpp and .h file for any class I want to create multiple instances of or can I keep the smaller classes in the same file and still create a new separate instance of the class?
I'm having trouble finishing this program. What I'm trying to do is create a class for Rational numbers. Get input from user for denominator and numerator. Store the numbers without a sign, and for the sign store it separately in char. I'm not supposed to use accessor functions. The part that I can't seem to know how to do is use the info that was stored in the addUp function. This function need to add two rational numbers. i need to make this function general enough that it can handle two fractions, or a fraction and a whole number, or two whole numbers. What I already have here is readin function which reads in the numerator and denominator. setnumerator and setdenominator to assign positive values. setsign should get the sign of the fraction. Finally addUp should addUp which I explained before. I have some ideas about writing the tests, but can't seem to know how to implement it to the program. The main program is still empty but all I'm supposed to do there is call the class functions.
Code: #include <iostream> using namespace std; class Rational { private: int numerator, denominator; char sign;
Is it possible to access file properties from c++ program? For example, user could drag file to program and then it displays a detailed information about file like date modified, size, type and etc..
I have startes making a game where there is 3 ships that cross the screen verticaly, and the point is to shoot them down. So far I have actually managed to do this. I have also managed to add gamescore to the ships. But here is my problem, I cant find a way to combine the score from all three ships in to one score. I have all three ships in different classes, is that wrong? When I try to combine the scores, ship score1 cant see the other scores.
Do I need to somehow have all the ships in one class. Or are there a way to read the scores from three classes, and adding them up in to one in a new class?
One of the errors I get is "the name 'score1' does not exist in the current context.
I've been attempting to design a multiform WFA in Visual Studio 2010, but I'm so rusty with the language it's hard to remember how to do a lot of things, especially when it comes to visual programming, which my class only partially covered. I've never made a multiform application before, and my problem essentially boils down to how to pass data between forms.
My application is a simple item list and order form, sort of mimicking what you might see on a site like Amazon or eBay. My first form contains a drop down list and 'checkout' button. The dropdown list has been populated with an object collection, each object holding the product's name and price.
public partial class Form1 : Form { //Item class for dropdown menu public class Item { public string Name; public decimal Price; public string itemName
[Code] ....
When the 'checkout' button on form 1 is clicked, I want the Price and Name properties of the selected droplist item to appear in a pair of text boxes on form 2 for the purpose of lowering the user's cognitive load (if they can see what they've selected, it's one less thing to remember).
I've seen plenty of tutorials on how to send a textbox Text property between forms, but none for how to do this. As I said, I'm rusty with the language, and I'm pretty sure there's a better way to set up my combobox items, but I can't remember how to set it up.
public class MyClass { public int age { get; set; } } static void Main(string[] args) { MyClass testing = new MyClass(); testing.age = 44; Console.WriteLine(testing.age); }
output: 44
Code using regular variable declaration:
public class MyClass { public int age; } static void Main(string[] args) { MyClass testing = new MyClass(); testing.age = 44; Console.WriteLine(testing.age); }
output: 44
Why use the auto-implemented property when you can just as equally use the second code block to achieve the same thing?
I have been trying to make a custom control(list box with more features). I know how to setup custom properties, but how do I make it so that the property can be edited in a separate window ?
I think I figured out how to show the form itself, and I don't know how to make the [...] button like :
There's not much Custom Control tutorials out there, and that's really the problem here.
Well I know how to pass values between forms using get and set properties. But the problem with it is everytime I want to pass values from form2 to form1 it doesn't appear. To make it appear I have to type form1.Show(); which open form1 a second time and then show the value. Is there any way I could make it appear without using form1.Show();?
Kinda like in properties, where you choose the height and width of the window, but in actual code. So everybody who open my program see the same window.
I'm trying to get my head around threading and gui applications for fun, and I've ran into a problem I'm not too sure how to google it correctly or I don't understand the answers given. Basically I'm trying to access GUI item properties (add to a listview). I've been on stackoverflow alot, and I've noticed that accessing these properties is quite difficult. At least, I'm not really understanding how it is supposed to be done.
The following line gives me a null value.
frm.lstChat.Items.Add(newList);
From what I understand I need to access my form object instead of creating a new object window... but I'm not sure how to reference the initial form application.
using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using System.Net.Sockets; using System.IO; using System.Threading; namespace ModBot {
How can I write my own container which has properties of both vector and list.
E.g. I can access elements directly using [] operator like vector and behave like list in terms of memory (means we don't have to shift elements if we want to insert in between like list)....
I want to make such application in which user make directed graphs along with relations between them. After that application show that which graph properties are proved in this graph e.g Reflexive, Irreflexive, Symmetric, Anti Symmetric, transitive etc
How would you create a video game in c++? I'm not sure really how to display the graphics and set properties and do all that stuff. I don't have money to buy a book about so how do you?
I'm developing C++ application in visual studio 2012. I have couple of C++ projects in my solution. I have put some library paths in every project's properties ( i.e ,Config properties - > C/C++ - > Additional Include Directories and Linker - > Additional Include directories ).I developed in debug mode, if i change to release mode, all library settings gone.Is there any possibility to retain all settings when change to debug to release mode and vice versa ?
I have researched quite extensively, experimented, and still cannot seem to change the properties of a control on an active winform from a user control.
So I have a user control which populates each dynamically added tab page in a tab control.
I have a textbox in the user control which I would like to type in, capture the text_change event, and change the text of the label in the winform.
Every time I run if(color=="1") it's supposed to add 1 to redTotal. However, every time I run if(color=="1") if get 1 for redTotal every time.
(Write a program that provides the option of tallying up the results of a poll with 3 possible values. The first input to the program is the poll question; the next three inputs are the possible answers. The first answer is indicated by 1, the second by 2, the third by 3. The answers are tallied until a 0 is entered. The program should then show the results of the poll—try making a bar graph that shows the results properly scaled to fit on your screen no matter how many results were entered.)
Code: #include <iostream> #include <string> using namespace std; int main()