Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Go Back   Code Forums > Application and Web Development > Standard C, C++
User Name
Password

Reply
 
LinkBack Thread Tools Display Modes
Old 10-06-2007, 12:21 AM   #1 (permalink)
markster
Code Monkey
 
markster's Avatar
 
Join Date: Jun 2006
Posts: 65
markster is on a distinguished road
Unhappy Total Beginner Question: Problems with classes

Hi. I've declared a class in my file and I want to use it within another class. So far i have this:

Code:
public class song { static public string track; static void Note(string note, string durr) { track += note+"*"+durr+"|"; } static void Play() { if (track.Length > 0) { // Some stuff } } }
and I'm trying to use it like this:

Code:
myTune; myTune = new MyNamespace.song();
I get the error that 'myTune' doesn't exist in the current context.

What am I doing wrong?
__________________
Stuff4Web.co.uk - The ultimate resource for webmasters

50% off all orders £1-£50! Just enter the code AGSIG01 at the checkout! Offer ends: 01/09/2008
markster is offline   Reply With Quote
Old 10-06-2007, 12:35 AM   #2 (permalink)
markster
Code Monkey
 
markster's Avatar
 
Join Date: Jun 2006
Posts: 65
markster is on a distinguished road
Never mind, I got it:

song myTune = new song();
__________________
Stuff4Web.co.uk - The ultimate resource for webmasters

50% off all orders £1-£50! Just enter the code AGSIG01 at the checkout! Offer ends: 01/09/2008
markster is offline   Reply With Quote
Old 10-06-2007, 12:44 AM   #3 (permalink)
markster
Code Monkey
 
markster's Avatar
 
Join Date: Jun 2006
Posts: 65
markster is on a distinguished road
Ah. I've got a new problem. I'm using this:

Code:
song myTune; myTune = new songPlayer.song(); myTune.Note("A", "WHOLE");
And i get the error:

Static member 'songPlayer.song.Note(string, string)' cannot be accessed with an instance reference; qualify it with a type name instead

What's going wrong?
__________________
Stuff4Web.co.uk - The ultimate resource for webmasters

50% off all orders £1-£50! Just enter the code AGSIG01 at the checkout! Offer ends: 01/09/2008
markster is offline   Reply With Quote
Old 10-08-2007, 12:46 PM   #4 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,545
Valmont is on a distinguished road
What does this mean:
Code:
new songPlayer.song()
?

You are looking for something like this:
Code:
Song* MyTune = new MyTune();
__________________
Valmont is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Total beginner, need help with my code! Urgent timeframe cleverest Standard C, C++ 3 03-20-2005 05:44 PM
Beginner - Borland Compiler question Redline Platform/API C++ 1 11-08-2004 01:34 AM


All times are GMT -8. The time now is 02:14 AM.


Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle