Jump to content
testForLinus.C: In function ‘int main()’:

testForLinus.C:6: error: ‘Clock’ was not declared in this scope

testForLinus.C:6: error: expected `;' before ‘myClock’

testForLinus.C:8: error: ‘call’ was not declared in this scope

testForLinus.C:8: error: expected `;' before ‘defualt’

testForLinus.C:9: error: ambiguous overload for ‘operator>>’ in ‘std::cin >> clock’

/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/istream:131: note: candidates are: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>& (*)(std::basic_istream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>] <near match>

/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/istream:134: note:                 std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_ios<_CharT, _Traits>& (*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>] <near match>

/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/istream:137: note:                 std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>] <near match>

testForLinus.C:9: error: expected `;' before ‘toString’

testForLinus.C:11: error: ‘System’ was not declared in this scope

testForLinus.C:11: error: ‘myClock’ was not declared in this scope

testForLinus.C:11: error: ‘printin’ was not declared in this scope

 

That's what I get when I put it into Unix :D

My arsenal: i7-9700k Gaming Rig, an iPhone, and Stupidity.

Link to post
Share on other sites

 

testForLinus.C: In function ‘int main()’:
testForLinus.C:6: error: ‘Clock’ was not declared in this scope
testForLinus.C:6: error: expected `;' before ‘myClock’
testForLinus.C:8: error: ‘call’ was not declared in this scope
testForLinus.C:8: error: expected `;' before ‘defualt’
testForLinus.C:9: error: ambiguous overload for ‘operator>>’ in ‘std::cin >> clock’
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/istream:131: note: candidates are: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>& (*)(std::basic_istream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>] <near match>
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/istream:134: note:                 std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_ios<_CharT, _Traits>& (*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>] <near match>
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/istream:137: note:                 std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>] <near match>
testForLinus.C:9: error: expected `;' before ‘toString’
testForLinus.C:11: error: ‘System’ was not declared in this scope
testForLinus.C:11: error: ‘myClock’ was not declared in this scope
testForLinus.C:11: error: ‘printin’ was not declared in this scope
 
That's what I get when I put it into Unix :D

 

how u get that stuff 

Link to post
Share on other sites

how u get that stuff 

I tried compiling it using the text cmmd "g++ [name of program]". Please note that I did not declare any of the items, though, and that probably led to most of mine's errors.

My arsenal: i7-9700k Gaming Rig, an iPhone, and Stupidity.

Link to post
Share on other sites

I tried compiling it using the text cmmd "g++ [name of program]". Please note that I did not declare any of the items, though, and that probably led to most of mine's errors.

i'm still trying to get the default constructor. Is Clock myClock = new Clock(); the constructor?

Link to post
Share on other sites

i'm still trying to get the default constructor. Is Clock myClock = new Clock(); the constructor?

I used int main() as the constructor, didnt even try that other one.

My arsenal: i7-9700k Gaming Rig, an iPhone, and Stupidity.

Link to post
Share on other sites

-snip-

That's what I get when I put it into Unix :D

 

 

Well that is what you get when you try compiling java code as c.  It just won't work (System.out.println is java :P)

 

 

To @airfrog19 Clock is an abstract class, which means you can't just create a clock.  Try something like

LocalTime clock = LocalTime.now();System.out.println(clock.tostring()); //Might have missed a capital or two

0b10111010 10101101 11110000 00001101

Link to post
Share on other sites

 

Well that is what you get when you try compiling java code as c.  It just won't work (System.out.println is java :P)

 

 

To @airfrog19 Clock is an abstract class, which means you can't just create a clock.  Try something like

LocalTime clock = LocalTime.now();System.out.println(clock.tostring()); //Might have missed a capital or two

That looks more betterer :D

My arsenal: i7-9700k Gaming Rig, an iPhone, and Stupidity.

Link to post
Share on other sites

 

Well that is what you get when you try compiling java code as c.  It just won't work (System.out.println is java :P)

 

 

To @airfrog19 Clock is an abstract class, which means you can't just create a clock.  Try something like

LocalTime clock = LocalTime.now();System.out.println(clock.tostring()); //Might have missed a capital or two

I think it's suppose to look like this:

public class ClockDemo
{
public static void main(String[] args)
{
//call default constructor
Clock myClock = new Clock();
//call clock toString method
System.out.println("My Clock: \t\t\t"+myClock.toString());
 
//call constructor with two arguments
Clock yourClock = new Clock(12,55);
System.out.print("Your Clock: \t\t\t");
yourClock.displayTime();
 
//call addMinute
myClock.addMinute();
System.out.print("My Clock (add 1 Minute): \t");
//call showTime method
myClock.displayTime();
 
//call addFiveMinutes
myClock.addFiveMinutes();
System.out.print("My Clock (add 5 Minutes): \t");
myClock.displayTime();
 
//call addHour
myClock.addHour();
System.out.print("My Clock (add 1 Hour): \t\t");
myClock.displayTime();
 
//call addTwelveHours
yourClock.addTwelveHours();
System.out.print("Your Clock (twelve hours later):");
yourClock.displayTime();
 
//call addTwelveHours
yourClock.addFiveMinutes();
System.out.print("Your Clock (five minutes later):");
yourClock.displayTime();
}
}
Link to post
Share on other sites

 

As others have pointed out, Clock appears to be a static class, unless you are supposed to be using a Clock class specifically for the project.

 

To import the Java Clock class, I think it would be:

import java.time.Clock;

i'm suppose to use it for this project

Link to post
Share on other sites

 

 

As others have pointed out, Clock appears to be a static class, unless you are supposed to be using a Clock class specifically for the project.

 

To import the Java Clock class, I think it would be:

import java.time.Clock;

i'm suppose to use it for this project

 

 

As has been pointed out, Clock can't be instantiated. Are you sure that you are supposed to be using the Java Clock class?

Link to post
Share on other sites

What were you doing the whole semester... You don't even know enough to ask a question.

Write the whole exercise and tell us why do you need it.

Is it homework/ exercise to prepare for a test/exam?

CPU: Ryzen 3 3600 | GPU: Gigabite GTX 1660 super | Motherboard: MSI Mortar MAX | RAM: G Skill Trident Z 3200 (2x8GB) | Case: Cooler Master Q300L | Storage: Samsung 970 EVO 250G + Samsung 860 Evo 1TB | PSU: Corsair RM650x | Displays: LG 27'' G-Sync compatible 144hz 1080p | Cooling: NH U12S black | Keyboard: Logitech G512 carbon | Mouse: Logitech g900 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×